use-wordpress-auth
Made with create-react-library
Install
npm install --save use-wordpress-auth
Wrap your App
with the AuthProvider
in App.js
import React from 'react'import AuthProvider from 'use-wordpress-auth'const App = return <AuthProvider>/* ... */</AuthProvider>
Usage
import React from 'react'import useForm from 'react-hook-form'import useAuth from 'use-wordpress-auth' const Example = const handleSubmit register errors = const user loading isAuthenticated login signup isAuthenticating = if isAuthenticated return <div>Welcome userfirstName!</div> return <form => <label ='email'>Email</label> <input ='email' ='email' = /> errorsemail && errorsemailmessage <label ='password'>Password</label> <input ='password' ='password' = /> errorspassword && errorspasswordmessage <button ='submit' => loading ? 'Loading...' : 'Login' </button> </form> }
License
MIT © Moretape