Replies: 17 comments 10 replies
-
Does zones not cover your use case? |
Beta Was this translation helpful? Give feedback.
-
Hello @ardyfeb, did you find any solution for easy subdomain routing with |
Beta Was this translation helpful? Give feedback.
-
Any input for this topic? It's possible to create multiple zones with a different subdomain and not based on the URL path? Thanks for this awesome tool! |
Beta Was this translation helpful? Give feedback.
-
Any updates on this topic? Would really love to have subdomain routing. |
Beta Was this translation helpful? Give feedback.
-
hopefully, Vercel will implement subdomain routing in the near future. a subdomain would be very useful in organizing links and pages. |
Beta Was this translation helpful? Give feedback.
-
I don't know if this is the right way to do this. But I'm able to reroute NextJS pages to subdomains using a custom express server. See: https://github.com/dcangulo/nextjs-subdomain-example |
Beta Was this translation helpful? Give feedback.
-
@dcangulo thank you for your example. However, your example assumes you create custom server. It will not work with serverless approach which has many benefits. |
Beta Was this translation helpful? Give feedback.
-
Any update on this?? |
Beta Was this translation helpful? Give feedback.
-
Any updates on this?? |
Beta Was this translation helpful? Give feedback.
-
I came across a thing called mono-repo, you can check it out here. It's not the exact way we wanted it to have, like subdomains routes handled in single serverless next.js project but it's kinda close to it. |
Beta Was this translation helpful? Give feedback.
-
I re-opened this issue because no official way to do this. @kushthakker @Jarrodsz @janmallari To work with this case i utilize webserver / reverse proxy (nginx / caddy) to rewrite url into subdomain. Example: |
Beta Was this translation helpful? Give feedback.
-
Any updates on single next app with subdomains? |
Beta Was this translation helpful? Give feedback.
-
Hi @ihadabs , |
Beta Was this translation helpful? Give feedback.
-
There are at least 3 ways to implement subdomains using Next.js. I advise reading the blog posts on the Vercel website that discuss some of these methods. How to Build a Multi-Tenant App with Custom Domains Using Next.jsSubdomains, wildcard domains, and apex domainsCan I redirect from a subdomain to a subpath?
An example rewrite object configuration inside next.config.js.. Only paths with app.acme.com will be rewritten. |
Beta Was this translation helpful? Give feedback.
-
I have a simpler usecase and struggling to make this work. I have the following in my next.config.ts, and have subfolders in my app with different pages and layouts. Although the redirect works - it seems to also try to redirect all the public and
I get 404 not found errors on all of the pages it tries to load such as |
Beta Was this translation helpful? Give feedback.
-
I struggled with this one a little, but I found a solution that's working nicely for me, and wanted to share. I don't know if it's the best way, but it works. My use case was pretty simple: most users will go to example.com, but an admin user will go to admin.example.com. I wanted to use two different layouts depending on the subdomain. I tried with routing, but I had some trouble getting it to work for me, and I wasn't sure if it was the right solution for my use case. Instead, I set response headers in a middleware function based on the host name. Something like:
Then, in the root component (not the layout because it wasn't working properly there), I used headers to check the header value, and rendered a component based on that value:
Of course, you'd have to handle auth in the admin page. For local development, I also had to modify my |
Beta Was this translation helpful? Give feedback.
-
I have this in my
in the The folder structure inside your
in the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Nextjs is awesome framework, but i have website with subdomain
I want to handle them on single app with nextjs, like laravel routing system allow use multiple subdomain on single app
Beta Was this translation helpful? Give feedback.
All reactions