Skip to content
Branch: master
Find file History
#6151 Compare This branch is 16 commits behind canary.
Type Name Latest commit message Commit time
Failed to load latest commit information.
pages Add docs to public (#7239) May 6, 2019
public Add docs to public (#7239) May 6, 2019 Add docs to public (#7239) May 6, 2019
next.config.js Add docs to public (#7239) May 6, 2019
now.json Move syntax formatting to prettier (#7454) May 29, 2019
package.json Switch all examples to `next@latest` (#7806) Jul 8, 2019

Public file serving example

How to use

Using create-next-app

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

npx create-next-app --example public-file-serving public-file-serving-app
# or
yarn create next-app --example public-file-serving public-file-serving-app

Download manually

Download the example:

curl | tar -xz --strip=2 next.js-canary/examples/public-file-serving
cd public-file-serving

Install it and run:

npm install
npm run dev
# or
yarn dev


Simply adjust your now.json (similar to in this example) by using the routes configuration.

Afterwards, deploy it to the cloud with now (download)


The idea behind the example

This example demonstrates how to serve files such as /robots.txt and /sitemap.xml from the root using the public folder in both a serverless and non-serverless environment.

You can’t perform that action at this time.