Next.js Discord

Discord Forum

Optional default locale in pathname with App Router

Unanswered
Barbary Lion posted this in #help-forum
Open in Discord
Barbary LionOP
We're building a new Next.js application using the App Directory. Is it possible to make the default locale optional in the pathname when localizing like you can with Pages? For example, domain.com resolves the same content as domain.com/en. We're using the app directory structure of app/[lang] and following the docs (https://nextjs.org/docs/app/building-your-application/routing/internationalization). We've also tried making the lang parameter optional via [[lang]] but we're getting the following error: Optional route parameters are not yet supported ("[[lang]]"). I'm hoping there is another way around this in the meantime 🙂

2 Replies

but tbh the app router doesn't support optional default locale all that well, just use a locale pathname as they want you to do, it doesn't look that bad either