Next.js Discord

Discord Forum

Optional section in router?

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
Hallo im in a situation where it would be handy if there was optional part of the route fx, "/[lang]/feature/[123]" and "/feature/[123]" would resolve in the same page content but using different layouts (for navigation bar and such)

is this currently possible in nextjs?

1 Reply

@Himalayan Hallo im in a situation where it would be handy if there was optional part of the route fx, "/[lang]/feature/[123]" and "/feature/[123]" would resolve in the same page content but using different layouts (for navigation bar and such) is this currently possible in nextjs?
Turkish Van
I assume You have a default language that would be chosen once You enter /feature/[123].

Just for an example, let's say Your default language was English.

What if /feature/[123] just redirects You to the /en/feature/[123] where the lang is "en"?

In that case. /feature/[123]/page.tsx page basically doesn't contain anything but a line of code that redirects You to /en/feature/[123].