MCPcopy Index your code
hub / github.com/vercel/platforms

github.com/vercel/platforms @main sqlite

repository ↗ · DeepWiki ↗
52 symbols 128 edges 22 files 0 documented · 0%
README

Next.js Multi-Tenant Example

A production-ready example of a multi-tenant application built with Next.js 15, featuring custom subdomains for each tenant.

Features

  • ✅ Custom subdomain routing with Next.js middleware
  • ✅ Tenant-specific content and pages
  • ✅ Shared components and layouts across tenants
  • ✅ Redis for tenant data storage
  • ✅ Admin interface for managing tenants
  • ✅ Emoji support for tenant branding
  • ✅ Support for local development with subdomains
  • ✅ Compatible with Vercel preview deployments

Tech Stack

Getting Started

Prerequisites

  • Node.js 18.17.0 or later
  • pnpm (recommended) or npm/yarn
  • Upstash Redis account (for production)

Installation

  1. Clone the repository:

bash git clone https://github.com/vercel/platforms.git cd platforms

  1. Install dependencies:

bash pnpm install

  1. Set up environment variables: Create a .env.local file in the root directory with:

KV_REST_API_URL=your_redis_url KV_REST_API_TOKEN=your_redis_token

  1. Start the development server:

bash pnpm dev

  1. Access the application:
  2. Main site: http://localhost:3000
  3. Admin panel: http://localhost:3000/admin
  4. Tenants: http://[tenant-name].localhost:3000

Multi-Tenant Architecture

This application demonstrates a subdomain-based multi-tenant architecture where:

  • Each tenant gets their own subdomain (tenant.yourdomain.com)
  • The middleware handles routing requests to the correct tenant
  • Tenant data is stored in Redis using a subdomain:{name} key pattern
  • The main domain hosts the landing page and admin interface
  • Subdomains are dynamically mapped to tenant-specific content

The middleware (middleware.ts) intelligently detects subdomains across various environments (local development, production, and Vercel preview deployments).

Deployment

This application is designed to be deployed on Vercel. To deploy:

  1. Push your repository to GitHub
  2. Connect your repository to Vercel
  3. Configure environment variables
  4. Deploy

For custom domains, make sure to:

  1. Add your root domain to Vercel
  2. Set up a wildcard DNS record (*.yourdomain.com) on Vercel

Core symbols most depended-on inside this repo

cn
called by 22
lib/utils.ts
getSubdomainData
called by 2
lib/subdomains.ts
extractSubdomain
called by 1
middleware.ts
isValidIcon
called by 1
lib/subdomains.ts
getAllSubdomains
called by 1
lib/subdomains.ts
middleware
called by 0
middleware.ts
Dialog
called by 0
components/ui/dialog.tsx
DialogTrigger
called by 0
components/ui/dialog.tsx

Shape

Function 52

Languages

TypeScript100%

Modules by API surface

components/ui/dialog.tsx10 symbols
components/ui/emoji-picker.tsx7 symbols
components/ui/card.tsx7 symbols
components/ui/popover.tsx4 symbols
app/subdomain-form.tsx4 symbols
lib/subdomains.ts3 symbols
app/admin/dashboard.tsx3 symbols
middleware.ts2 symbols
app/s/[subdomain]/page.tsx2 symbols
app/actions.ts2 symbols
lib/utils.ts1 symbols
components/ui/label.tsx1 symbols

Dependencies from manifests, versioned

@radix-ui/react-dialog1.1.13 · 1×
@radix-ui/react-label2.1.6 · 1×
@radix-ui/react-popover1.1.13 · 1×
@radix-ui/react-slot1.2.2 · 1×
@types/node22.15.17 · 1×
@types/react19.1.4 · 1×
@types/react-dom19.1.5 · 1×
@upstash/redis1.34.9 · 1×
@vercel/analytics1.5.0 · 1×
@vercel/speed-insights1.2.0 · 1×
class-variance-authority0.7.1 · 1×

For agents

$ claude mcp add platforms \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact