nextauthjs / nextauthjs/next-auth

Use auth js toghether with next-intl

Open
#13,083 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

What is the improvement or update you wish to see?

Im struggling on how to write a middleware that can works fine with next-intl.

Is there any context that might help us understand?

i've tried this so far, but i have some problems....can you help me?

import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';
import { auth } from '@/lib/auth';
import createIntlMiddleware from 'next-intl/middleware';
import { routing } from './i18n/routing';

const intl = createIntlMiddleware(routing);

export default async function middleware(
    req: NextRequest,
    ev: NextFetchEvent
) {

    const intlRes = await intl(req);
    if (intlRes) {
        return intlRes;
    }


    const authRes = await auth(req, ev);
    return authRes ?? NextResponse.next();
}

export const config = {
    matcher: '/((?!api|_next/static|_next/image|favicon.ico).*)',
};

Does the docs page already exist? Please link to it.

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the middleware snippet and inspect the referenced @/lib/auth and ./i18n/routing entry points, along with the next-intl middleware and matcher configuration. Reproduce the reported integration problem and define done as a documented, working way to use Auth.js with next-intl without breaking either middleware flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
authentication, internationalization, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.