SuperTokens

SuperTokens

  • Docs
  • Discord
  • Blog

›Multi Tenancy

SIDEBAR_REPLACE_DOC_Introduction

  • Introduction

Quick setup

  • Video tutorial & Architecture
  • Frontend
  • Backend
  • Core

    • Core Overview
    • Self Hosted setup with Docker
    • Self Hosted setup without Docker
    • Managed Service

    Database Setup

    • MySQL
    • PostgreSQL

Common customizations

  • Sign Out
  • Sign Up Form

    • About
    • Adding Extra Fields
    • Adding / Modifying field validators
    • Embed in a page
    • Handling signup success
    • Terms of service & Privacy policy links

    Sign In Form

    • About
    • Adding / Modifying field validators
    • Password managers
    • Embed in a page
    • Show Sign In by default

    Reset Password

    • About
    • Reset password email
    • Embed in a page

    Email Verification

    • About
    • Customising the email sent
    • Embed in a page

    Sessions

    • About
    • Cookie Consent
    • Creating a new session
    • Session Verification in API
    • Change session timeout
    • Checking if a session exists on the frontend
    • Get user information on the frontend
    • Using with FaunaDB

    Styling

    • Changing Colours
    • Changing Style via CSS
    • Themes

    Changing base path

    • Website Base Path
    • API Base Path

    Multi Tenancy

    • About
    • One login, many sub domains
    • One login per sub domain
  • User Pagination

Advanced users

    Advanced session management

    • Share sessions across sub domains
    • Anti CSRF
    • JWT Signing key rotation
    • Access token blacklisting
    • Customizing Error Handling

    Supertokens Core config

    • Adding API Keys
    • Tuning Performance
    • Logging
    • Rename database tables

    Make your own frontend

    • Sign-up / Sign-in custom theme
    • Reset password custom theme

    Make your own backend

    • Sign up custom API
    • Sign in custom API
    • Reset password custom APIs

NextJS

  • SuperTokens with NextJS
  • Deploy with Vercel
  • Deploy with Netlify

SIDEBAR_REPLACE_DOC_SDKs

  • SDKs

SIDEBAR_REPLACE_DOC_Compatibility Table

  • Compatibility Table

Migration

  • Migrating from an older version of SuperTokens
  • Migrating to SuperTokens
  • Migrating away from SuperTokens
  • From managed service to self hosted

One login per sub domain

We will demonstrate the changes required for this with an example:

  • Customer 1: Let's say that the name of the customer is abc. In this case, we want them to login via abc.example.com/auth and get redirected to use abc.example.com after login.
  • Customer 2: Let's say that the name of the customer is xyz. In this case, we want them to login via xyz.example.com/auth and get redirected to use xyz.example.com after login.

Frontend setup:

  • Change the init function params for abc.example.com
    SuperTokens.init({
        appInfo: {
            appName: "YOUR APP NAME",
            apiDomain: "YOUR API DOMAIN",
            websiteDomain: "abc.example.com",
        },
        recipeList: [...]
    });
    
  • Change the init function params for xyz.example.com
    SuperTokens.init({
        appInfo: {
            appName: "YOUR APP NAME",
            apiDomain: "YOUR API DOMAIN",
            websiteDomain: "xyz.example.com",
        },
        recipeList: [...]
    });
    

We set different websiteDomain values per customer.

Backend setup:

  • Change the init function params in accordance with the frontend
    supertokens.init({
        appInfo: {
            appName: "YOUR APP NAME",
            apiDomain: "YOUR API DOMAIN",
            websiteDomain: "example.com"
    
        },
        recipeList: [
            EmailPassword.init({
                resetPasswordUsingTokenFeature: {
                    getResetPasswordURL: (user) => {
                        let {id, email} = user;
    
                        // getUserDomain is your implementation
                        let userDomain = await getUserDomain(userId);
    
                        return `https://${userDomain}.example.com/reset-password`;
                    }
                },
    
                emailVerificationFeature: {
                    getEmailVerificationURL: (user) => {
                        let {id, email} = user;
    
                        // getUserDomain is your implementation
                        let userDomain = await getUserDomain(userId);
    
                        return `https://${userDomain}.example.com/verify-email`;
                    }
                },
            }),
            Session.init()
        ]
    });
    
← One login, many sub domainsUser Pagination →