Simple and lightweight middleware for handling subdomains in Express.js applications. Current stable version is 1.0.6, with minimal releases since initial publication. Key differentiators: zero dependencies, supports multi-level subdomains, wildcards, and chaining. Simpler than alternatives like vhost, focusing only on subdomain routing without virtual hosting features.
npm install express-subdomainVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic subdomain routing with Express Router and wildcard subdomain middleware.
Ensure app.use(subdomain(...)) is placed before app.get('/', ...).Use explicit multi-level subdomain strings like 'v1.api' or chain subdomain middleware for deeper nesting.
Add entries to /etc/hosts or use tools like ngrok to test subdomains.
Run 'npm install express-subdomain' and use 'import subdomain from 'express-subdomain'' in ESM code.
Use 'import subdomain from 'express-subdomain'' (default import) instead of 'import { subdomain }...'.