{"repo":"koole/react-sanctum","free":true,"listed":false,"github":"https://github.com/koole/react-sanctum","clone":"git clone https://github.com/koole/react-sanctum.git","description":"Easily hook up your React app to Laravel Sanctum and Laravel Fortify","language":"PHP","stars":152,"topics":["react-components","react","sanctum","laravel-sanctum","authentication","laravel-fortify","two-factor-authentication"],"license":"MIT","category":"auth-billing-email","readme_excerpt":"Introduction React Sanctum package provides an easy way to authenticate your React application with Laravel Sanctum. - Easily hook up your React app to Laravel Sanctum - Works with both hooks and class components - Built in support for two factor authentication with Laravel Fortify - Just one dependency: axios Usage Install from NPM Wrap your application in a component Example You can then use the useSanctum() hook to get authentication status, user data and sanctum related methods in any component. Or use the withSanctum() higher-order component to get these same values. You can also directly consume the Sanctum context by importing SanctumContext . The useSanctum hook and the withSanctum HOC give you access to the SanctumContext , which contains the following data and methods: Description - ------------------------------------------------------------------------------------ user Object your API returns with user data authenticated Boolean, or null if authentication has not yet been checked signIn() Accepts (email, password, remember?) , returns a promise, resolves with {twoFactor: boolean, signedIn: boolean, user: {}} . signOut() Returns a promise setUser() Accepts (user, authenticated?) , allows you to manually set the user object and optionally its authentication status (boolean). twoFactorChallenge() Accepts (code, recovery?) , returns a promise, resolves with the user object. checkAuthentication() Returns the authentication status. If it's null, it will ask the server a","default_branch":null,"files":null,"tree":[],"storefront":"/r/koole","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/koole/react-sanctum/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}