Next.js ↔️ Stytch Migration Guide
Create your Stytch account following our guide.
You can find your public token in the Stytch dashboard.
Also remove the magic key from your .env if you have one.
Visit the file where you wrap your app in ChordProvider and add a stytchClient:
Then, pass the stytchClient to the auth prop of the ChordProvider:
Finally, wrap children with a StytchProvider (import from @stytch/nextjs) and pass stytchClient.getServiceClient() to it:
Go to the config docs to see what options are available. Please note that you will need to wrap the <StytchLogin /> component with another <StytchProvider /> . This is because the <StytchLogin /> component depends on Stytch's UI client, which is quite heavy, and that chord-stytch uses the headless client for it's normal operations.
This component will authenticate the user by calling handleCallback() from useAuth, then it will navigate to the /account page.
Add this component to the pages directory.
Visit your login page and try logging in using a magic link!
Once you've clicked the link in the email from Stytch to sign-up/login, you can visit the User management page to see your user.
If your would like to enable OAuth, visit the SDK Configuration page, and click the OAuth toggle. Then, expand the OAuth section and toggle Enable PKCE.
Once OAuth is enabled, visit the OAuth page, then select the provider you would like to use and follow the directions.