This quickstart will get you up and running with auth in about 10 minutes.
Install @userfront/react
with npm.
UserfrontProvider
to the root layout of your applicationInitialize the Userfront UI Toolkit for React with your workspace ID using the UserfrontProvider
. You should wrap your root layout with this so that forms can be placed anywhere in your application.
Add the SignupForm
where you want end users to sign up to your application.
Give it a try: fill out your signup form and submit it.
Upon successful signup, the form does 2 things:
Redirects the browser to /dashboard
.
We'll edit this next.
Adds a secure access token named access.<YOUR WORKSPACE_ID>
to your browser's cookies.
This token is a JWT with the user's information, which you can send to your own backend.
Your form is in test mode, which means it creates a user record in your test environment when the form is submitted.
In your Redirect paths page, update the After-signup path to /home
.
Now when you re-submit your signup form, you should be redirected to /home
.
Follow the same process for your other tools:
/login
page./reset
page.For logout most of our users typically choose to call Userfront.logout()
from Userefront's core.js library directly.
Read more about CoreJS#logout here.
To install the prebuilt logout button follow these instructions.
Userfront forms and API calls operate in the context of a "mode", either live
or test
mode. When you deploy your forms to any of your live domains and the browser is using HTTPS, the forms will operate in live
mode automatically, otherwise they will operate in test
mode.
Read more about the differences between live & test mode here.
Congratulations, you've added auth to your site.
To enable live
mode, add your website to the list of live domains on the Live domains page.