Skip to main content

Overview

MagenX404 publishes TypeScript source files, which requires Next.js to be configured to transpile the package.

Quick Setup

Add this to your next.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 your tsconfig.json includes the package:

Verification

After configuration:
  1. Restart your Next.js dev server:
  2. Test the import:
  3. 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:
The "use client" directive is required when using MagenX404 features in Next.js App Router components.

Using in Server Components

You cannot directly use MagenX404 features in Server Components since they require browser APIs. However, you can:
  1. Create a Client Component wrapper
  2. Use the Client Component in your Server Component

Troubleshooting

”Module not found” errors

  1. Verify transpilePackages is configured:
  2. Restart the dev server:
  3. Clear Next.js cache:
  4. Reinstall the package:

Type errors

  1. Check tsconfig.json includes the package:
  2. Verify TypeScript can find types:

Build errors

  1. Update Next.js to latest version:
  2. Ensure TypeScript version is compatible:

Alternative: next-transpile-modules (Legacy)

If the above doesn’t work, you can use next-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