/
Contact usSee pricingStart building
    Overview
    Installation
    Changelog

    Pre-built UI

    Component Playground
    StytchLogin
      UI Configuration
      UI Callbacks
    StytchPasswordReset
    StytchPasskeyRegistration
    IdentityProviderBeta
      UI Configuration
      UI Callbacks

    Headless

    Users
      Get user
      Update user
      Delete authentication factors
    Email Magic Links
      Send
      Login or create
      Authenticate
    OAuth
      Start
      Google One Tap
      Authenticate
    Passwords
      Create
      Authenticate
      Reset by Email Start
      Reset by Email
      Reset by Existing Password
      Reset by Session
      Strength Check
    One-Time Passcodes (OTP)
      Login or create via SMS
      Send via SMS
      Login or create via Email
      Send via Email
      Login or create via WhatsApp
      Send via WhatsApp
      Authenticate
    Time-Based One-Time Passcodes (TOTP)
      Create
      Authenticate
      Get Recovery Codes
      Recover
    Session Management
      Get Session
      Authenticate Session
      Revoke Session
      Update Session
      Get Tokens
    Passkeys & WebAuthn
      Register
      Authenticate
      Update
      Browser supports autofill
    Crypto Wallets
      Authenticate
      Authenticate Start
    Impersonation
      Authenticate

    More Resources

    Cookies & session management
    SWR & caching
    TypeScript
    User privacy measures
    Multi-factor authentication
    Next.js
    CAPTCHA
Get support on SlackVisit our developer forum

Contact us

Consumer Authentication

/

Frontend SDKs

/

More Resources

/

TypeScript

TypeScript

Stytch's JavaScript SDK is written in TypeScript and includes its own type definitions. In most cases, no extra configuration is necessary.

Stytch project configuration

Some parts of the SDK behave differently depending on how your Stytch project has been configured. For example, stytch.session.getTokens() does not return a session token if the project is using HttpOnly cookies.

You can customize these behaviors and get more accurate type information by specifying your Stytch project's configuration. The easiest way to do this is by using declaration merging to extend the Stytch.DefaultProjectConfiguration interface.

For example, add a stytch.d.ts file to your project like this:

// stytch.d.ts
declare namespace Stytch {
  interface DefaultProjectConfiguration extends ProjectConfiguration {
    OpaqueTokens: false;
  }
}

This configuration will be used for your entire project. If necessary, you can override the configuration on a per-type basis by specifying a custom configuration type based on StytchProjectConfiguration as a generic type parameter.

OpaqueTokens

Whether sensitive tokens are omitted from response bodies. Set this to true when HttpOnly cookies are enforced for the project.

Stytch project configuration

OpaqueTokens