rsnext/examples/with-zones
Kristoffer K 2acb53bd30
chore: update example names to match their folders (#16268)
**What's the problem this PR addresses?**

A decent amount of the examples don't have a `name` field in `package.json` that matches their folder name, meaning they either lack a name or the names are duplicated.

I was testing Yarn 2 workspaces using the entire examples directory and needed to get rid of the duplicates.

**How did you fix it?**

Updated the names to match the names of their folders
2020-09-05 21:23:51 +00:00
..
blog Update examples React to 16.13.1 (#14899) 2020-07-07 03:58:13 +00:00
home Update examples React to 16.13.1 (#14899) 2020-07-07 03:58:13 +00:00
.gitignore Added .gitignore to examples that are deployed to vercel (#15127) 2020-07-16 10:52:23 -04:00
package.json chore: update example names to match their folders (#16268) 2020-09-05 21:23:51 +00:00
README.md Undo unrequired readme changes done to examples (#16831) 2020-09-03 19:11:58 +00:00
vercel.json Update instances of Now to Vercel where applicable (#13760) 2020-06-04 14:57:17 +00:00

Using multiple zones

With Next.js you can use multiple apps as a single app using its multi-zones feature. This is an example showing how to use it.

  • All pages should be unique across zones. For example, the home app should not have a pages/blog/index.js page.
  • The blog app sets assetPrefix so that generated JS bundles are within the /blog subfolder.
    • To also support the plain next dev scenario, assetPrefix is set dynamically based on the BUILDING_FOR_NOW environment variable, see vercel.json and blog/next.config.js.
    • Images and other static assets have to be prefixed manually, e.g., <img src={`${process.env.ASSET_PREFIX}/static/image.png`} />, see blog/pages/blog/index.js.

Deploy your own

Deploy the example using Vercel:

Deploy with Vercel

How to use

Execute create-next-app with npm or Yarn to bootstrap the example:

npx create-next-app --example with-zones with-zones-app
# or
yarn create next-app --example with-zones with-zones-app

Install the dependencies of every app (/home and /blog):

npm install
# or
yarn

Install the Vercel CLI if you don't have it already, and then run vercel dev in the main directory to start the development server:

vercel dev

Your app should be up and running on http://localhost:3000!

We recommend vercel dev in this case instead of next dev, as it can start both apps at the same time and use the routes defined in vercel.json

Deploy it to the cloud with Vercel (Documentation).