jose library and optimize dependencies.
Why Bundler Configuration?
The underlying Logto SDK uses thejose library for JWT handling, which can cause bundling issues in some environments. logto-authkit provides ready-to-use configurations that:
- Resolve
joselibrary compatibility issues - Optimize dependency bundling
- Ensure proper module resolution
Vite Configuration
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 thegetBundlerConfig helper:
Parameters
ThegetBundlerConfig function accepts one parameter:
The bundler type to get configuration for
Merging with Existing Config
You can merge the provided configuration with your existing setup:vite.config.js
Troubleshooting
Module not found: jose
Module not found: jose
Make sure you’ve applied the bundler configuration. The
jose alias resolves to the CommonJS distribution which is more compatible with bundlers.React errors during build
React errors during build
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.Vite optimization errors
Vite optimization errors
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