I want to support multiple domains (e.g., app.example.com and admin.example.com). To clarify, I’m not trying to create a multi-tenancy app with custom domains.
These subdomains don’t share pages. app.example.com is for normal users and admin.example.com is for admins.
Should I create separate apps for each domain, or is there a way to assign separate domains for a set of routes inside a single Next.js project?
You could do this with some middleware magic, but seeing as the subdomains don’t share pages I’d actually suggest that you have two separate apps for each domain.
Creating separate applications for app.example.com and admin.example.com is better for separation of concerns, security, scalability, and routing simplicity, allowing for independent management and general maintenance of each subdomain.
I’ll go with creating separate Next.js applications for each subdomain. I’ll probably use Turborepo so that some code can be shared easily while separating these applications.