Overview
MagenX404 publishes TypeScript source files, which requires Next.js to be configured to transpile the package.Quick Setup
Add this to yournext.config.js or next.config.mjs:
Next.js 13+ (App Router)
The above configuration works for Next.js 13+ with the App Router. No additional setup needed.Next.js 12 (Pages Router)
For Next.js 12, use this webpack configuration:TypeScript Configuration
Make sure yourtsconfig.json includes the package:
Verification
After configuration:-
Restart your Next.js dev server:
-
Test the import:
-
If you see errors, clear the cache:
Using in Client Components
Since MagenX404 uses browser APIs (wallet connections, localStorage), you must use it in Client Components:Using in Server Components
You cannot directly use MagenX404 features in Server Components since they require browser APIs. However, you can:- Create a Client Component wrapper
- Use the Client Component in your Server Component
Troubleshooting
”Module not found” errors
-
Verify
transpilePackagesis configured: -
Restart the dev server:
-
Clear Next.js cache:
-
Reinstall the package:
Type errors
-
Check
tsconfig.jsonincludes the package: -
Verify TypeScript can find types:
Build errors
-
Update Next.js to latest version:
-
Ensure TypeScript version is compatible:
Alternative: next-transpile-modules (Legacy)
If the above doesn’t work, you can usenext-transpile-modules:
This is a legacy approach. The
transpilePackages option is preferred for
Next.js 13+.Next Steps
Quick Start
Start using MagenX404 in your Next.js app
Features
Explore available authentication features