Skip to main content
Our frontend SDK provide automatic session management, prebuilt login or signup, multi-step flow handling, and more. They can also be used alongside our backend API or SDKs.

Quickstart

This quickstart guides you through building a login or signup flow. Select a framework:

Example apps

End-to-end consumer examples

Node.js SDK

Stytch Node.js library

API reference

API & SDK references
1

Before you start

  • Have your project_id and secret_key from your Stytch project & environment.
  • Add http://localhost:3000/authenticate as a redirect URL in your Dashboard.
2

Install the Node.js SDK and configure API keys

  1. Install the SDK:
npm
  1. Then add your Stytch API keys to your project’s .env file:
.env
3

Set up your app and login routes

  1. Initialize the Stytch client with your environment variables.
  2. Create a /login route that takes in a user’s email address and initiates the login or signup flow.
POST '/login'
4

Add a route to handle Stytch's redirect callback

  1. Stytch calls your authenticate redirect URL with a token to complete the flow.
  2. Add an /authenticate route to mint a session:
GET '/authenticate'
5

Add a session-protected route

  1. Create a helper method that authenticates a session.
  2. Use the method to gate any protected route.
GET '/dashboard'
6

Full completed example:

Test your application

  • Run your application and send a POST request to the /login endpoint with your email address.
  • You should receive an email magic link in your inbox.
  • Click the link to finish the login or signup flow.

Next steps