Skip to main content
logto-authkit provides pre-configured bundler settings to resolve common issues with the jose library and optimize dependencies.

Why Bundler Configuration?

The underlying Logto SDK uses the jose library for JWT handling, which can cause bundling issues in some environments. logto-authkit provides ready-to-use configurations that:
  • Resolve jose library compatibility issues
  • Optimize dependency bundling
  • Ensure proper module resolution

Vite Configuration

When editing a Vite config or other build-time script, import directly from the bundler-config subpath. This avoids executing the main library bundle (which pulls in React and may cause issues during Node startup).
vite.config.js

What’s Included

The Vite configuration provides:

Webpack Configuration

webpack.config.js

What’s Included

The Webpack configuration provides:

Next.js Configuration

next.config.js

What’s Included

The Next.js configuration provides the same alias configuration as Webpack:

Custom Configuration

If you need more control or want to integrate the configuration differently, you can use the getBundlerConfig helper:

Parameters

The getBundlerConfig function accepts one parameter:
bundler
'vite' | 'webpack' | 'nextjs'
default:"'vite'"
The bundler type to get configuration for

Merging with Existing Config

You can merge the provided configuration with your existing setup:
vite.config.js
The bundler configuration is minimal and designed to be easily merged with your existing setup. It only modifies what’s necessary for logto-authkit to work properly.

Troubleshooting

Make sure you’ve applied the bundler configuration. The jose alias resolves to the CommonJS distribution which is more compatible with bundlers.
If you’re importing from the main package in your build config, switch to importing from @ouim/logto-authkit/bundler-config instead. This avoids loading React during the build process.
If you see errors about pre-bundling dependencies, make sure the optimizeDeps.include array includes both @logto/react and @ouim/better-logto-react.

Next Steps

Guest Mode

Learn how to enable guest mode for unauthenticated users

Custom Navigation

Set up custom navigation with your router