Multi-Tenancy Example
Demonstrates multi-tenant support using @venturekit-pro/tenancy.
Source: examples-code/multi-tenancy/
Key Concepts Demonstrated
Section titled “Key Concepts Demonstrated”- Tenant resolution — resolve tenants from subdomains, headers, or JWTs
- Tenant middleware — automatic resolution per request
- Tenant context —
ctx.tenant.id,ctx.tenant.slug - Quota enforcement — per-tenant usage limits
- Error handling —
TenantNotFoundError,QuotaExceededError
Middleware Setup
Section titled “Middleware Setup”middleware: [ createTenantMiddleware({ config: { strategy: 'shared', resolution: 'subdomain' }, lookupTenant: async (id) => loadTenant(id), }), createQuotaMiddleware({ quotaKey: 'apiRequests', checkUsage: async (tenantId) => getMonthlyUsage(tenantId), }),]Run It
Section titled “Run It”cd venturekit-doc/examples-code/multi-tenancynpm installvk dev