-
multitenant-nextjs
Discontinued a test repository for testing Next.js' multi-tenant capabilities with a custom Express.js server
-
krabs
Discontinued 🦀 Express.js/Fastify middleware and virtual host for multi-tenant Next.js applications
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
next-js-monorepo
A monorepo approach for Next.js that lets you have multiple discrete Next.js sites while sharing modules, components and NPM dependencies.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
In this approach, a custom server is set up and maps individual sites to their own folders inside your pages folder. You can do this manually yourself (here is one example), but I will focus on a great library available for this called 🦀 Krabs.
Krabs.
Next.js recently added support for Rewrites - essentially a regex matching engine that supports rewriting parts of the query. More importantly, you can dynamically match on headers, cookies, and query parameters. A multitenancy approach using rewrites was developed.
Surprisingly, this approach worked! It's only about 10 lines of bash code and doesn't touch Next.js. It supports individual API and public folders, and you could even deploy it to Vercel. (In your CI, you would switch to each site, build it and then deploy it to Vercel.
Sometimes it's convenient to have one Next.js codebase serve multiple discrete sites. The sites might have different content and design but also share code - such as having the same React component to render the header or sidebar.
Related posts
-
System & Database Design (Day 1) - Creating a SaaS Startup in 30 Days
-
Epic Next.js 14 Tutorial: Learn Next.js by building a real-life project: Part 1
-
best approach to fetch data based on state in nextjs 13
-
My experience deploying a Next.js application on Netlify (using Next App Router)
-
Need examples of good structured applications to follow