2. Backend config
#
1) Install supertokens packagenpm i supertokens-node
config/supertokensConfig.js
)#
2) Create a configuration file (- Create a
config
folder in the root directory of your project. - Create a
supertokensConfig.js
inside theconfig
folder. - An example of this file can be found here.
#
3) Create a backend config functionHow do you want to identify your users?
Only phone numberOnly emailEmail or phone number
Which authentication type will you use?
OTPMagic linksOTP and Magic link
- Single app setup
- Multi app setup
/config/supertokensConfig.ts
import Passwordless from 'supertokens-node/recipe/passwordless';
import Session from 'supertokens-node/recipe/session'
function getBackendConfig() {
return {
framework: "awsLambda",
supertokens: {
connectionURI: "",
apiKey: "",
},
appInfo: {
// learn more about this on https://supertokens.com/docs/passwordless/appinfo
appName: "<YOUR_APP_NAME>",
apiDomain: "<YOUR_API_DOMAIN>",
websiteDomain: "<YOUR_WEBSITE_DOMAIN>",
apiBasePath: "/auth",
websiteBasePath: "/auth"
},
recipeList: [
Passwordless.init({
flowType: "USER_INPUT_CODE",
contactMethod: "PHONE"
}),
Session.init(),
],
isInServerlessEnv: true,
}
}
module.exports.getBackendConfig = getBackendConfig;
/config/supertokensConfig.ts
import Passwordless from 'supertokens-node/recipe/passwordless';
import Session from 'supertokens-node/recipe/session'
function getBackendConfig() {
return {
framework: "awsLambda",
supertokens: {
connectionURI: "",
apiKey: "",
},
appInfo: {
// learn more about this on https://supertokens.com/docs/passwordless/appinfo
appName: "<YOUR_APP_NAME>",
apiDomain: "<YOUR_API_DOMAIN>",
websiteDomain: "<YOUR_WEBSITE_DOMAIN>",
apiBasePath: "/auth",
websiteBasePath: "/auth"
},
recipeList: [
Passwordless.init({
flowType: "USER_INPUT_CODE",
contactMethod: "PHONE"
}),
Session.init(),
],
isInServerlessEnv: true,
}
}
module.exports.getBackendConfig = getBackendConfig;
#
4) Set up your email / sms delivery methodHow do you want to identify your users?
Only phone numberOnly emailEmail or phone number
- Using your Twilio account
- SuperTokens SMS service
- Custom method with full control
By default, if nothing is configured, the SDK will send SMSs using our APIs (https://api.supertokens.com
). This is rate limited and is only meant for development / demo purposes.
You can learn more about each of these methods in the "SMS Delivery" section under "Auth Flow Customizations" (find it in the navigation list on the left).