Vercel for Platforms
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(req: NextRequest) {
// Route each tenant's subdomain to a shared dynamic segment
const host = req.headers.get('host') ?? '';
const tenant = host.split('.')[0];
return NextResponse.rewrite(
new URL(`/tenants/${tenant}${req.nextUrl.pathname}`, req.url),
);
}Most platforms on Vercel follow one of two patterns. Pick the one that matches how isolated each customer needs to be:
| Approach | Codebase and deployment | Complexity | Best for |
|---|---|---|---|
| Multi-tenant | One codebase, one deployment serves every tenant | Lower | Content and branding differ, but functionality is the same (documentation sites, website builders, SaaS dashboards) |
| Multi-project | One project and deployment per tenant | Higher | Each tenant needs custom code or isolated infrastructure (AI coding platforms, user-generated apps) |
For a multi-tenant build, clone the Platforms Starter Kit. For a multi-project build, create and deploy tenant projects with the Vercel SDK.
Teams run many kinds of platforms on Vercel:
- Content platforms, such as Hashnode and Dub.
- Documentation platforms, such as Mintlify, Fern, and Plain.
- Website and store builders, such as Super, Typedream, and Universe.
- B2B SaaS platforms, such as Zapier, Instatus, and Cal.
A typical setup gives you a root domain for your platform (acme.com), subdomains for tenants (tenant1.acme.com), and fully custom domains for customers who want them (tenantcustomdomain.com).
- Unlimited custom domains and
*.yourdomain.comsubdomains. - Automatic SSL. Vercel issues and renews certificates for every tenant domain.
- Programmatic domain management through the REST API or the Vercel SDK.
- Global low-latency routing over the Vercel CDN and Anycast network.
- Preview deployments so you can test tenant changes before they ship.
- Support for 35+ frontend and backend frameworks.
Multi-tenant platforms
Serve many customers from one codebase with custom domains and subdomains.
Multi-project platforms
Give each customer an isolated project and deployment, created with the SDK.
Examples
Clone working multi-tenant and multi-project starters.
Platform elements
Drop in prebuilt actions and UI blocks for domains and deployments.
Starter template
Deploy a multi-tenant Next.js app with subdomain routing and tenant storage.
Was this helpful?