
How I Built a Multi-Tenant Documentation Platform with Next.js 15 (Subdomain Routing, MDX, and ISR)
I recently built Dokly , a documentation platform where users get instant subdomains (like acme.dokly.co ) for their docs. Think Mintlify/GitBook but affordable. Here's the technical deep-dive on how multi-tenant subdomain routing works in Next.js 15, including the gotchas that took me days to figure out. The Architecture Challenge The goal was simple: one Next.js app serving multiple purposes: dokly.co → Marketing site app.dokly.co → Dashboard (auth, editor) *.dokly.co → User documentation sites docs.acme.com → Custom domains (Pro feature) All from a single deployment. No separate apps. No complex infrastructure. The Secret: Middleware Routing Next.js middleware intercepts every request before it hits your pages. We use it to rewrite URLs based on the hostname. // middleware.ts import { NextResponse } from " next/server " ; import type { NextRequest } from " next/server " ; export function middleware ( request : NextRequest ) { const hostname = request . headers . get ( " host " ) ||
Continue reading on Dev.to Webdev
Opens in a new tab



