Skip to content
Esc
navigateopen⌘Jpreview
Dashboard

Supporting other backend frameworks

Set up an authentication server with SuperTokens for unsupported backend frameworks.

If your backend framework is not supported by SuperTokens, you can follow this guide on setting up an authentication server to protect your frontend and backend.

A key feature of the SuperTokens backend SDK is the middleware it adds to your backend server. This middleware adds authentication routes to handle requests like user creation and login. If your backend framework is not supported by SuperTokens, you need to run a separate server with the SuperTokens backend SDK configured. This could be a service in NodeJS, Python, or Golang.

To illustrate how this setup works, consider an example:

  • The user has a React based frontend and a PHP backend server.
  • SuperTokens does not have a PHP SDK, and a separate service in NodeJS starts to act as an authentication server. The SuperTokens backend SDK configures this server to handle authentication requests and the issuing of access and refresh tokens.
  • The architecture of setup should have the following design:
SuperTokens setup with an authentication server
  • In the architecture above the the React Frontend communicates with the PHP and node server through a reverse proxy.
  • Authentication requests like sign-up or sign-in route to the NodeJS server. These APIs are automatically created and handled by the supertokens-node SDK. On the other hand, your application-specific APIs are on the PHP server.
  • Once a user signs up or signs in, the system creates a session between your API server’s domain and the frontend.
  • Application requests to the PHP server have session tokens attached to them.
  • The session token is a JWT, and the PHP server can verify it.
  • When verifying a request, if the session token is missing or has expired, the PHP server should return a 401 response. This prompts the SuperTokens Frontend SDK to trigger the automatic refresh flow to generate new session tokens and retry the request.

API reference

API schema and response details