0.1.0 • Published 3 years ago

next-multisite v0.1.0

Weekly downloads
4
License
MIT
Repository
-
Last release
3 years ago

next-multisite

This package wraps around next, allowing you to host multiple domains from one project.

Usage

For a complete example, see the example folder.

Installation

Install next-multisite instead of installing next

npm install next-multisite

Folder structure

next-multisite uses the following folder structure to serve multiple sites. Sites are selected by the first part of the domain name, so in this example site1.example.com and site2.example.com would be served correctly.

sites
  /site1
    /pages
      /page.js
      /other-page.js
  /site2
    /pages
      /page.js
      /other-page.js

Running next-muultisite

Run next-multisite for both development and production build. If the NODE_ENV variable is set to production, next build output is used.

"scripts": {
    "dev": "next-multisite",
    "build": "next build",
    "start": "cross-env NODE_ENV=production next-multisite"
}

Accessing sites locally

By default, domains ending in .localhost will all map to your local machine. Thus, you can easily open your different sites by going to http://site1.localhost:3000/, http://site2.localhost:3000/, etc.. When starting the process, these urls will be printed automatically.