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.