Skip to main content

From 21 to 22

Compatibility

  • Browser support: We support Safari mobile and desktop 16, Chrome 109 and Firefox 106. Browsers older than this may still be able to use our SDK, but may require additional transpile and polyfills.
  • No polyfills are included since all APIs used are also supported in the versions supported.
  • Custom themes require support for color-mix CSS function. A compatibility helper is available if you are targeting older browsers.

Step by step guide

1

Upgrade @stytch/nextjs and remove @stytch/vanilla-js

vanilla-js is now included in @stytch/nextjs and no longer a peer dependency. Run npm, yarn or pnpm to install the new version.
package.json
"@stytch/nextjs": "^21.0.0", 
"@stytch/vanilla-js": "^5.0.0", 
"@stytch/nextjs": "^22.0.0", 
2

Update imports

Copy all imports from @stytch/vanilla-js to @stytch/nextjs.
import { StytchProvider } from '@stytch/nextjs'; 
import { StytchHeadlessClient, createStytchUIClient } from '@stytch/vanilla-js'; 
import { 
  StytchHeadlessClient,
  StytchProvider,
  createStytchUIClient
} from '@stytch/nextjs';
3

Update products configuration

If config.products are specified as strings, update them to use Products instead:
import { Products } from '@stytch/nextjs'; 

const config = {
  products: ['oauth', 'eml'], 
  products: [Products.oauth, Products.emailMagicLinks], 
};
4

Update styles to presentation

The new presentation property now controls theming and styling options. This differs from the previous style property in that it configures tokens affecting many elements rather than properties on specific elements.We have provided a migration helper function. In development mode this function will also print out warnings about properties that could not be migrated.
import { styleToTheme } from '@stytch/nextjs/compat'; 

const config = {
  style: { ... }, 
  // This will also print out the recommended migrated config
  // which should replace this in production
  theme: styleToTheme({ ... }),
};
For a full list of supported properties, see reference documentation for presentation.

presentation.theme

Controls CSS styling. Each token corresponds to some CSS properties, so each value should be a CSS value. You can also provide an array of [lightTheme, darkTheme] which will automatically switch between the two depending on the user's OS color scheme.

presentation.options

Controls non-styling options such as the logo to display.

More styling changes

These changes are unlikely to cause issues.
5

Update customized strings

If you use string customization, check if you need to update these strings:You may also wish to customize these new strings:
6

Update deprecated imports

The following are deprecated and should be updated.
  • createStytchUIClientcreateStytchClient
  • createStytchHeadlessClientcreateStytchClient
7

Test your changes

We recommend running through every auth method used to make sure the new theme looks correct in context. You should also take note of errors or warnings in the browser console.