u-bx31
u-bx31

Reputation: 11

Remove /en prefix from url | nextjs 13 app directory

I'm usign i18next app directory and i'm wondoring if there is an option to remove language prefix from url

My goal

to have url like this

My environment:

Upvotes: 1

Views: 1260

Answers (2)

yohai
yohai

Reputation: 1

Take a look at rewrite something like:

if (locale === DEFAULT_LOCALE) {
  return NextResponse.rewrite(new URL(`${locale}${pathname}`, request.url));
}

Upvotes: 0

Phước Nguyễn
Phước Nguyễn

Reputation: 11

In my opinion, you could try this flow:

  • en for home page example.com
  • en for login page example.com/login
  • fr for home page example.com/fr
  • fr for login page example.com/fr/login

And i found an example for this (nextjs 13, use app dir) and im using it, its work: https://carlogino.com/blog/nextjs13-i18n

Hope this help!

Upvotes: 1

Related Questions