Deploy the example using ZEIT Now:
Execute create-next-app with Yarn or npx to bootstrap the example:
npx create-next-app --example with-zones with-zones-app
# or
yarn create next-app --example with-zones with-zones-appDownload the example:
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-zones
cd with-zonesWith Next.js you can use multiple apps as a single app using it's multi-zones feature. This is an example showing how to use it.
In this example, we have two apps: 'home' and 'blog'. We'll start both apps with Now:
now devThen, you can visit http://localhost:3000 and develop for both apps as a single app.
You can also start the apps separately, for example:
cd blog
yarn dev- All pages should be unique across zones. For example, the 'home' app should not have a
pages/blog/index.jspage. - The 'blog' app sets
assetPrefixso that generated JS bundles are within the/blogsubfolder.- To also support the plain
next devscenario,assetPrefixis set dynamically based on theBUILDING_FOR_NOWenvironment variable, seenow.jsonandblog/next.config.js. - Images and other
/staticassets have to be prefixed manually, e.g.,<img src={`${process.env.ASSET_PREFIX}/static/image.png`} />, seeblog/pages/blog/index.js.
- To also support the plain
We only need to run now, the same now.json used for development will be used for the deployment:
now