Next.js Multi‑Tenant Architecture

Hero image for Next.js Multi‑Tenant Architecture. Image by Jason Richard.
Hero image for 'Next.js Multi‑Tenant Architecture.' Image by Jason Richard.

Multitenant architecture sounds tidy until the second tenant arrives.

One tenant is a variation. Two tenants are a pattern. Ten tenants are a platform. At that point the hard work is no longer whether Next.js can route requests. It is whether the system has clear rules for domains, configuration, content, permissions, caching, analytics, preview, and ownership.

The technical shape has to serve the operational shape. If every tenant needs a developer to change a colour, publish a page, add a redirect, or fix a menu item, the platform is not really multitenant. It is a shared codebase with expensive exceptions.


Define Tenant Boundaries First

Before choosing implementation details, define what a tenant owns.

Examples:

  • domain or subdomain
  • locale or market
  • theme tokens
  • navigation
  • homepage content
  • page templates
  • product or service catalogue
  • analytics identifiers
  • SEO metadata defaults
  • feature flags
  • user accounts
  • permissions
  • preview access

The mistake is to store "tenant" as a string and let that string spread through the application. A tenant is not just an ID. It is a bundle of rules.

The existing article on building a multitenant application with Next.js covers the implementation introduction. The architecture question is what should vary, what should be shared, and who is allowed to change each part.


Choose Domain and Routing Strategy Deliberately

Common routing models include:

  • subdomains, such as brand.example.com
  • custom domains per tenant
  • path prefixes, such as /branda/
  • locale and market prefixes
  • mixed models for internal tools and public sites

Each model has tradeoffs.

Custom domains are often better for public brand separation, but they require domain verification, SSL, canonical discipline, and analytics configuration. Path prefixes are easier to reason about in one domain but may be wrong for independent brands. Subdomains sit somewhere between the two.

Next.js and Vercel both have patterns for multitenant sites, and the Next.js multitenant guide is worth reading. The key point is to make the route model match the business model. Do not choose paths because they are easy if each tenant is meant to behave like a separate brand.


Keep Configuration Typed and Boring

Tenant configuration should be easy to inspect.

Good configuration usually includes:

  • tenant ID
  • canonical host
  • allowed hosts
  • default locale
  • theme token reference
  • CMS space, environment, or root entry
  • analytics IDs
  • feature flags
  • sitemap inclusion rules
  • robots policy
  • contact or enquiry destinations
  • support links

Avoid large, untyped blobs of arbitrary JSON. They feel flexible until a production tenant breaks because a required field was renamed.

For serious platforms, configuration should be validated before deploy and before publish. A tenant missing a canonical host, theme, CMS root, or analytics setting should fail loudly.


Separate Content Variation from Template Variation

Not every tenantspecific need requires tenantspecific code.

Ask whether the difference is:

  • content
  • theme
  • layout option
  • feature flag
  • data source
  • template variant
  • genuinely custom behaviour

Content and theme variation should usually live outside the component tree. Template variants can be supported if the options are constrained. Custom behaviour should be rare and owned carefully.

This is where multibrand platforms often go wrong. Every exception feels reasonable. Six months later, the shared system is full of brandspecific branches.

Keeping scope under control on large multibrand websites covers the delivery side of that problem.


Cache by Tenant, Not Just Route

Caching mistakes are more serious in multitenant systems.

Check:

  • tenant ID is part of cache keys where required
  • domainspecific content cannot leak across tenants
  • revalidation targets the right tenant
  • sitemap generation is tenantaware
  • preview mode is tenantaware
  • image metadata and theme assets are scoped correctly
  • CDN caching respects host and path rules

If two tenants share the same route path, the host or tenant ID usually needs to be part of the cache boundary. Otherwise one tenant's content can appear under another tenant's domain.

The details differ between Pages Router, App Router, Vercel, and custom hosting, but the principle is stable: cache keys need to include every dimension that changes the response.


Make Preview and Publishing Tenant‑Aware

Editors need to preview the correct tenant.

That means preview URLs should include enough information to resolve:

  • tenant
  • locale
  • content entry
  • draft state
  • route
  • permissions

If preview always opens the default tenant, editors will stop trusting it. If preview bypasses tenant permissions, it becomes a security problem. If cache invalidation only updates one domain, content teams will see inconsistent publishes.

Preview is also where CMS modelling decisions become obvious. If a shared article can appear on three tenant sites, does it have tenantspecific metadata? Tenantspecific canonical URLs? Tenantspecific related content? Those are product decisions as much as technical ones.


Design Ownership Before the Platform Grows

Multitenant systems fail socially before they fail technically.

Decide:

  • who owns shared components
  • who approves tenantspecific exceptions
  • who changes theme tokens
  • who owns redirects
  • who owns analytics
  • who handles CMS schema changes
  • who reviews performance and SEO impact
  • who supports production issues

This is the same kind of boundary work discussed in designing ownership boundaries in large web platforms. Without ownership, the shared platform becomes a queue of unrelated requests.


Wrapping Up

Next.js can support multitenant platforms well, but the architecture is not just routing.

The hard parts are deciding what varies, validating tenant configuration, scoping content and cache correctly, making preview trustworthy, and keeping ownership clear as the number of tenants grows.

The best multitenant platforms feel boring in the right places. Adding a tenant should be a controlled process, not an archaeological dig through conditionals.

Key Takeaways

  • Define what a tenant owns before choosing route mechanics.
  • Pick domains, subdomains, or paths based on the business model.
  • Keep tenant configuration typed, validated, and inspectable.
  • Separate content, theme, template, and custom behaviour.
  • Include tenant identity in cache and revalidation boundaries.
  • Decide ownership rules before tenantspecific exceptions multiply.

Planning a platform change?

I help teams make difficult platform work clearer, from architecture decisions and migrations to launch recovery, performance, and search visibility.