Skip to content

Middleware enhancements after new Next.js middleware architecture #1362

@amannn

Description

@amannn

Is your feature request related to a problem? Please describe.

It seems like there's work happening on the Next.js side on a middleware revamp: vercel/next.js#46722 (comment)

I'm using this thread to collect aspects about the current next-intl middleware that we could potentially address in case a revamp is relevant after the Next.js change.

Describe the solution you'd like

My personal wishlist for Next.js:

  1. Passing a locale to the rendering phase (see Reading params deeply in Server Components (e.g. for i18n / multi-tenancy) vercel/next.js#58862). Ideally this would be possible without a middleware in the first place though. Update: Seems like this is coming as rootParams.
  2. Easy exclusion of: Next.js internals _next, static files (both public as well as generated by Next.js from icon.png & friends)
  3. A dynamically created matcher

Mentioned here.

Separately from this, there are some use cases we could support better that do not rely on Next.js:

  1. Get the locale within middleware #1356
  2. Locale detection could be more flexible #1369
  3. Feature Request: RoutingConfig for Locale Cookie Sync Control #1793
  4. Maybe opting out of root redirect? Possible already by adapting the matcher, but would there be an advantage to make this more explicit?
    We can make these changes in any case, but in case a refactoring is necessary after the Next.js change, maybe it'd be worth waiting a bit.
  5. Ability to disable routing redirects #2056

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions