Built-in NextAuth Functions
NextAuth (or AuthJS) is an open source authentication library for web applications like NextJS, Svelte, Express, or SolidStart. As a native NextAuth Provider, Descope can be seamlessly integrated into your application whether you are already using NextAuth or adding it from scratch.
Be sure to check out our Getting Started guide for initializing a project from scratch here. This page simply covers the key functions relevant to implementing NextAuth with Descope.
Functions
Sign in
Signing in a user involves calling the sign in function from NextAuth and passing a provider name of descope
in order for the Descope provider to be used.
You can also pass a callback URL to redirect the user to after they've signed in. This will redirect the user to the Descope login page and then back to your application.
The authentication flow that is redirected to can be found, and customized, in your Descope console, as elaborated on here.
Sign out
For signing out a user, you'll have to sign out of both Descope and NextAuth.
This can be done by calling the signOut
function for NextAuth and then a federatedSignOut
Server Action for Descope. The code could look something like this:
The federatedSignOut
Server Action is a custom function that you'll create in your NextJS application.
NextAuth options
Customize
Now that you have the end-to-end application working with all of the built-in NextAuth functions, you can choose to configure and personalize many different areas of Descope, including your brand, style, custom user authentication journeys, etc. We recommend starting with customizing your user-facing screens, such as signup and login.