Skip to main content
Version: Next

Supertokens.init(config)

In your index.js, you need to call the Supertokens.init function to initialise SuperTokens. You can provide it the following config:

import supertokens from "supertokens-node";

Supertokens.init({
framework?: string,
supertokens?: {
connectionURI: string,
apiKey?: string
};
appInfo: {
appName: string,
apiDomain: string,
websiteDomain: string,
apiBasePath?: string,
websiteBasePath?: string,
apiGatewayPath?: string
},
recipeList: RecipeListFunction[],
isInServerlessEnv?: boolean
})

Parameters#

framework (Optional)#

  • Pass the value of framework this library is used in. For next.js, use express. Currently supported values are:
    • express
    • koa
    • hapi
    • fastify
    • loopback
    • awsLambda
  • Default: express

supertokens#

  • connectionURI
    • The url link to supertokens core. If you are using Supertokens Saas service, you can find the connectionURI on your app's dashboard.
  • apiKey (Optional)
    • Use this to authenticate the backend APIs with the supertokens core
    • Default: undefined

appInfo#

  • You can learn more about the appInfo object in the recipe guides.

isInServerlessEnv(Optional)#

  • Pass true if you are using this library in a serverless environment as it will help to optimise the performance.
  • Default: false

recipeList#

  • List of Recipes you want to use. You need to pass atleast one Recipe to ths array. For more info on Recipes, checkout this link) or the other sections in this docs.