Skip to main content

Backend Integration

Example#

An example implementation can be found here.

1) Install#

npm i -s supertokens-node

2) Initialise SuperTokens#

Please fill the form below to see the code snippet (* = Required)
Your app's name:*
Information about the question
This is the name of your application
API Domain:*
Information about the question
This is the URL of your app's API server.
API Base Path:
Information about the question
SuperTokens will expose it's APIs scoped by this base API path.
Website Domain:*
Information about the question
This is the URL of your website.
Website Base Path:
Information about the question
SuperTokens UI will be shown on this website route.
Submit form

3) Add the SuperTokens APIs & CORS setup#

Please fill the form below to see the code snippet (* = Required)
API Base Path:
Information about the question
SuperTokens will expose it's APIs scoped by this base API path.
Website Domain:*
Information about the question
This is the URL of your website.
Submit form

4) Add the SuperTokens error handler#

import express, { Request, Response, NextFunction } from 'express';import { errorHandler } from "supertokens-node/framework/express";
let app = express();
// ...your API routes
// Add this AFTER all your routesapp.use(errorHandler())
// your own error handlerapp.use((err: unknown, req: Request, res: Response, next: NextFunction) => { /* ... */ });

5) Test if sign up is setup correctly#

  • Visit the login form on the website.
  • Try to sign up.
  • If after signing up, you are redirected to /, everything is setup correctly 😁
  • If not, you can always ask for help via Github issues or via our Discord

6) Setup the SuperTokens core#

Are you using https://try.supertokens.com as the connection URI in the init function?
YesNo