Skip to main content

Flexible architecture

Stytch is architected to be embedded directly into your application, offering you flexibility and control over your integration and creating a seamless and native experience for users. Most customers mix-and-match approaches to fit their needs:

Using the frontend SDK

Headless Overview
Using the frontend SDK headlessly enables you to build your own custom auth flow — directly on the frontend. However, there are certain operations that can only be done with a backend implementation. A high-level implementation might look like:
  1. The end user attempts to log into your application with your custom UI.
  2. Your frontend handles the UI events, collects all the necessary authentication data, and then utilizes Stytch’s frontend SDK methods to call the Stytch API to perform an auth-related operation.
  3. Stytch API processes the request and returns a response with pertinent data.
  4. Your frontend handles the response as needed, which may involve calling the Stytch API again, updating your UI, or relaying the data to your backend.
  5. Once the end user successfully authenticates, Stytch’s frontend SDK automatically manages the storage of session tokens using browser cookies or mobile storage.

Using the backend SDK or API

Backend Overview
As the most feature-complete and flexible option, our backend API and SDKs enable you to tightly integrate Stytch’s auth primitives with your application’s logic. A high-level, server-side implemention of Stytch would look like:
  1. Your backend collects all necessary authentication data (e.g., IDs, tokens, emails, and metadata) and calls the Stytch API to perform a specific auth related operation (e.g., initiate an auth flow, retrieve an organization or member record, and refresh a session).
  2. Stytch API processes the request and returns a response with pertinent data (e.g., minted session, organization data, auth metadata, and statuses).
  3. Your backend handles the response and transforms the data as needed, which may involve calling the Stytch API again, passing the data to a different backend or microservice, or relaying data back to your frontend.