Next.js Discord

Discord Forum

Next.js 14 redirect

Unanswered
Maxx posted this in #help-forum
Open in Discord
is this true?
In Next.js, when you use the redirect function and specify a URL with a leading slash (e.g., /example), it will perform a client-side redirect. This means that the browser will make a new request to the specified URL, resulting in an additional fetch.
On the other hand, when you use the redirect function without a leading slash (e.g., example), Next.js will perform a server-side redirect. In this case, the server will send a redirect response to the client, instructing it to make a new request to the specified URL. The client will then follow the redirect and make a single request to the new URL.

because I have an issue when use redirect it fetch two times with "/" infront when I remove "/" it fetch one time but I cannot find any explanation about it in Nextjs site.

0 Replies