🏠 Home
Hello! This is a publicly accessible home page.
It can be accessed
by both the / and
/home paths. By simply
setting a cookie, Vercel can take logged-in users to
/dashboard using a redirect
or a rewrite.
How does this demo work?
Change the my-router-cookie cookie in the navbar and navigate
around.
When set to:
null- the URLs will behave conventionally. Visiting
/will show this Home page, and visiting/dashboardwill show the Dashboard page.No bueno. This is default behavior but it's not a good user experience because users will have to click a link to navigate to their dashboard every time they visit your website.
redirect- visiting
/redirects to/dashboardBetter. This may cause a slight delay while the redirect occurs, but Vercel does it server-side and it's still really fast.
rewrite- visiting
/shows the contents of/dashboardwithout changing the URLBest. This creates a seamless experience where visiting acme.com shows the website for public users and the dashboard for logged-in users.
How do logged-in users see the home page?
Good question. It would suck to force your users to log out before they
can see your website. That's why companies reserve /home as a
route for logged-in users. Here are some examples:
This demo has gone ahead and done that, so try clicking /home
with a redirect or rewrite cookie set.