Integrating SuperTokens with a Next.js app involves:
- Calling the frontend and backend init functions
- Adding a website page to display the auth related widgets (on
- Creating a serverless function to expose the auth related APIs which will be consumed by the frontend widgets (on
- Protecting website routes: Displaying them only when a user is logged in, else redirecting them to the login page
- Performing session verification:
- In your APIs
Each of these will be covered in the next few pages. Rest of the customizations can be done by following the "Common customizations" section.
See the GitHub repo or start a new project using:
npx create-next-app --example with-supertokens with-supertokens-app# oryarn create next-app --example with-supertokens with-supertokens-app
This example uses the ThirdPartyEmailPassword recipe. If you want to use another recipe, you can still use this as a starting point and change the configurations.