+ )
+}
+
+// Use SSR for this page as currently rewrites don't work with dynamic pages without SSR
+export async function getServerSideProps(context) {
+ return {
+ props: {},
+ }
+}
diff --git a/examples/rewrites/styles.module.css b/examples/rewrites/styles.module.css
new file mode 100644
index 0000000000000..cd7bec9b86a9b
--- /dev/null
+++ b/examples/rewrites/styles.module.css
@@ -0,0 +1,51 @@
+.container {
+ padding: 4rem 1rem;
+ font-family: -apple-system, BlinkMacSystemFont, sans-serif;
+}
+
+.container p {
+ margin: 1.5rem 0;
+}
+
+.card {
+ max-width: 50rem;
+ box-shadow: -10px 10px 80px rgba(0, 0, 0, 0.12);
+ border: 1px solid #eee;
+ border-radius: 8px;
+ padding: 2rem;
+ margin: 0 auto;
+}
+
+.inlineCode {
+ color: #be00ff;
+ font-size: 16px;
+ white-space: pre-wrap;
+}
+
+.inlineCode::before,
+.inlineCode::after {
+ content: '`';
+}
+
+.hr {
+ border: 0;
+ border-top: 1px solid #eaeaea;
+ margin: 1.5rem 0;
+}
+
+.list {
+ padding-left: 1.5rem;
+ margin: 1.25rem 0;
+ list-style-type: none;
+}
+
+.list li {
+ margin-bottom: 0.75rem;
+}
+
+.list li:before {
+ content: '-';
+ color: #999999;
+ position: absolute;
+ margin-left: -1rem;
+}
diff --git a/examples/with-mongodb/.env.local.example b/examples/with-mongodb/.env.local.example
new file mode 100644
index 0000000000000..0bc8a2ce22f98
--- /dev/null
+++ b/examples/with-mongodb/.env.local.example
@@ -0,0 +1,2 @@
+MONGODB_URI=
+MONGODB_DB=
\ No newline at end of file
diff --git a/examples/with-mongodb/.gitignore b/examples/with-mongodb/.gitignore
new file mode 100644
index 0000000000000..20fccdd4b84d9
--- /dev/null
+++ b/examples/with-mongodb/.gitignore
@@ -0,0 +1,30 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# next.js
+/.next/
+/out/
+
+# production
+/build
+
+# misc
+.DS_Store
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# local env files
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
diff --git a/examples/with-mongodb/README.md b/examples/with-mongodb/README.md
new file mode 100644
index 0000000000000..2f88e28478dc2
--- /dev/null
+++ b/examples/with-mongodb/README.md
@@ -0,0 +1,79 @@
+## Example app using MongoDB
+
+[MongoDB](https://www.mongodb.com/) is a general purpose, document-based, distributed database built for modern application developers and for the cloud era. This example will show you how to connect to and use MongoDB as your backend for your Next.js app.
+
+If you want to learn more about MongoDB, visit the following pages:
+
+- [MongoDB Atlas](https://mongodb.com/atlas)
+- [MongoDB Documentation](https://docs.mongodb.com/)
+
+## Deploy your own
+
+Once you have access to the environment variables you'll need, deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
+
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/git?c=1&s=https://github.com/vercel/next.js/tree/canary/examples/with-mongodb&env=MONGODB_URI,MONGODB_DB&envDescription=Required%20to%20connect%20the%20app%20with%20MongoDB)
+
+## How to use
+
+### Using `create-next-app`
+
+Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
+
+```bash
+npx create-next-app --example with-mongodb with-mongodb
+# or
+yarn create next-app --example with-mongodb with-mongodb
+```
+
+## Configuration
+
+### Set up a MongoDB database
+
+Set up a MongoDB database either locally or with [MongoDB Atlas for free](https://mongodb.com/atlas).
+
+### Set up environment variables
+
+Copy the `env.local.example` file in this directory to `.env.local` (which will be ignored by Git):
+
+```bash
+cp .env.local.example .env.local
+```
+
+Set each variable on `.env.local`:
+
+- `MONGODB_URI` - Your MongoDB connection string. If you are using [MongoDB Atlas](https://mongodb.com/atlas) you can find this by clicking the "Connect" button for your cluster.
+- `MONGODB_DB` - The name of the MongoDB database you want to use.
+
+### Run Next.js in development mode
+
+```bash
+npm install
+npm run dev
+
+# or
+
+yarn install
+yarn dev
+```
+
+Your app should be up and running on [http://localhost:3000](http://localhost:3000)! If it doesn't work, post on [GitHub discussions](https://github.com/zeit/next.js/discussions).
+
+You will either see a message stating "You are connected to MongoDB" or "You are NOT connected to MongoDB". Ensure that you have provided the correct `MONGODB_URI` and `MONGODB_DB` environment variables.
+
+When you are successfully connected, you can refer to the [MongoDB Node.js Driver docs](https://mongodb.github.io/node-mongodb-native/3.4/tutorials/collections/) for further instructions on how to query your database.
+
+## Deploy on Vercel
+
+You can deploy this app to the cloud with [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
+
+#### Deploy Your Local Project
+
+To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and [import to Vercel](https://vercel.com/import/git?utm_source=github&utm_medium=readme&utm_campaign=next-example).
+
+**Important**: When you import your project on Vercel, make sure to click on **Environment Variables** and set them to match your `.env.local` file.
+
+#### Deploy from Our Template
+
+Alternatively, you can deploy using our template by clicking on the Deploy button below.
+
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/git?c=1&s=https://github.com/vercel/next.js/tree/canary/examples/with-mongodb&env=MONGODB_URI,MONGODB_DB&envDescription=Required%20to%20connect%20the%20app%20with%20MongoDB)
diff --git a/examples/with-mongodb/package.json b/examples/with-mongodb/package.json
new file mode 100644
index 0000000000000..284a43b5e5618
--- /dev/null
+++ b/examples/with-mongodb/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "with-mongodb",
+ "version": "0.1.0",
+ "scripts": {
+ "dev": "next dev",
+ "build": "next build",
+ "start": "next start"
+ },
+ "dependencies": {
+ "mongodb": "^3.5.9",
+ "next": "latest",
+ "react": "^16.13.1",
+ "react-dom": "^16.13.1"
+ },
+ "license": "MIT"
+}
diff --git a/examples/with-mongodb/pages/index.js b/examples/with-mongodb/pages/index.js
new file mode 100644
index 0000000000000..d2f47e31f09e7
--- /dev/null
+++ b/examples/with-mongodb/pages/index.js
@@ -0,0 +1,233 @@
+import Head from 'next/head'
+import { connectToDatabase } from '../util/mongodb'
+
+export default function Home({ isConnected }) {
+ return (
+
+ )
+}
+
+export async function getServerSideProps(context) {
+ const { client } = await connectToDatabase()
+
+ const isConnected = await client.isConnected() // Returns true or false
+
+ return {
+ props: { isConnected },
+ }
+}
diff --git a/examples/with-mongodb/public/favicon.ico b/examples/with-mongodb/public/favicon.ico
new file mode 100644
index 0000000000000..4965832f2c9b0
Binary files /dev/null and b/examples/with-mongodb/public/favicon.ico differ
diff --git a/examples/with-mongodb/public/vercel.svg b/examples/with-mongodb/public/vercel.svg
new file mode 100644
index 0000000000000..fbf0e25a651c2
--- /dev/null
+++ b/examples/with-mongodb/public/vercel.svg
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/examples/with-mongodb/util/mongodb.js b/examples/with-mongodb/util/mongodb.js
new file mode 100644
index 0000000000000..f5a50bcfeebe6
--- /dev/null
+++ b/examples/with-mongodb/util/mongodb.js
@@ -0,0 +1,37 @@
+import { MongoClient } from 'mongodb'
+
+let uri = process.env.MONGODB_URI
+let dbName = process.env.MONGODB_DB
+
+let cachedClient = null
+let cachedDb = null
+
+if (!uri) {
+ throw new Error(
+ 'Please define the MONGODB_URI environment variable inside .env.local'
+ )
+}
+
+if (!dbName) {
+ throw new Error(
+ 'Please define the MONGODB_DB environment variable inside .env.local'
+ )
+}
+
+export async function connectToDatabase() {
+ if (cachedClient && cachedDb) {
+ return { client: cachedClient, db: cachedDb }
+ }
+
+ const client = await MongoClient.connect(uri, {
+ useNewUrlParser: true,
+ useUnifiedTopology: true,
+ })
+
+ const db = await client.db(dbName)
+
+ cachedClient = client
+ cachedDb = db
+
+ return { client, db }
+}
diff --git a/examples/with-polyfills/README.md b/examples/with-polyfills/README.md
index 360159375bb82..0ac052ada46a3 100644
--- a/examples/with-polyfills/README.md
+++ b/examples/with-polyfills/README.md
@@ -1,5 +1,7 @@
# Example app with polyfills
+> ❗️ Warning: This example is not the suggested way to add polyfills and is known to cause issues with bundling. See [the browser support docs](https://nextjs.org/docs/basic-features/supported-browsers-features#custom-polyfills) for the correct way to load polyfills.
+
Next.js supports modern browsers and IE 11. It loads required polyfills automatically. If you need to add custom polyfills, you can follow this example.
## Deploy your own
diff --git a/examples/with-sentry/README.md b/examples/with-sentry/README.md
index 4b1200bccea59..cd458d3d713f4 100644
--- a/examples/with-sentry/README.md
+++ b/examples/with-sentry/README.md
@@ -24,27 +24,6 @@ npx create-next-app --example with-sentry with-sentry
yarn create next-app --example with-sentry with-sentry
```
-### Download Manually
-
-Download the example:
-
-```bash
-curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-sentry
-cd with-sentry
-```
-
-Install it and run:
-
-```bash
-npm install
-npm run dev
-# or
-yarn
-yarn dev
-```
-
-Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
-
## Configuration
### Step 1. Enable error tracking
@@ -75,10 +54,19 @@ Your app should be up and running on [http://localhost:3000](http://localhost:30
### Step 3. Automatic sourcemap upload (optional)
+#### Using Vercel
+
+You will need to install and configure the [Sentry Vercel integration](https://docs.sentry.io/workflow/integrations/vercel). After you've completed the project linking step, all the needed environment variables will be set in your Vercel project.
+
+> **Note:** A Vercel project connected to a [Git integration](https://vercel.com/docs/v2/platform/deployments#git-integration) is required before adding the Sentry integration.
+
+#### Without Using Vercel
+
1. Set up the `NEXT_PUBLIC_SENTRY_DSN` environment variable as described above.
-2. Save your Sentry Organization slug as the `SENTRY_ORG` environment variable and your project slug as the `SENTRY_PROJECT` environment variable in `.env.local`.
-3. Create an auth token in Sentry. The recommended way to do this is by creating a new internal integration for your organization. To do so, go into **Settings > Developer Settings > New internal integration**. After the integration is created, copy the Token.
-4. Save the token inside the `SENTRY_AUTH_TOKEN` environment variable in `.env.local`.
+2. Save your Sentry organization slug as the `SENTRY_ORG` environment variable and your project slug as the `SENTRY_PROJECT` environment variable in `.env.local`.
+3. Save your git provider's commit SHA as either `VERCEL_GITHUB_COMMIT_SHA`, `VERCEL_GITLAB_COMMIT_SHA`, or `VERCEL_BITBUCKET_COMMIT_SHA` environment variable in `.env.local`.
+4. Create an auth token in Sentry. The recommended way to do this is by creating a new internal integration for your organization. To do so, go into **Settings > Developer Settings > New internal integration**. After the integration is created, copy the Token.
+5. Save the token inside the `SENTRY_AUTH_TOKEN` environment variable in `.env.local`.
> **Note:** Sourcemap upload is disabled in development mode using the `NODE_ENV` environment variable. To change this behavior, remove the `NODE_ENV === 'production'` check from your `next.config.js` file.
diff --git a/examples/with-sentry/next.config.js b/examples/with-sentry/next.config.js
index f20aab6c0c627..7b8cb6549d6e6 100644
--- a/examples/with-sentry/next.config.js
+++ b/examples/with-sentry/next.config.js
@@ -10,8 +10,16 @@ const {
SENTRY_PROJECT,
SENTRY_AUTH_TOKEN,
NODE_ENV,
+ VERCEL_GITHUB_COMMIT_SHA,
+ VERCEL_GITLAB_COMMIT_SHA,
+ VERCEL_BITBUCKET_COMMIT_SHA,
} = process.env
+const COMMIT_SHA =
+ VERCEL_GITHUB_COMMIT_SHA ||
+ VERCEL_GITLAB_COMMIT_SHA ||
+ VERCEL_BITBUCKET_COMMIT_SHA
+
process.env.SENTRY_DSN = SENTRY_DSN
module.exports = withSourceMaps({
@@ -44,6 +52,7 @@ module.exports = withSourceMaps({
SENTRY_ORG &&
SENTRY_PROJECT &&
SENTRY_AUTH_TOKEN &&
+ COMMIT_SHA &&
NODE_ENV === 'production'
) {
config.plugins.push(
@@ -51,7 +60,7 @@ module.exports = withSourceMaps({
include: '.next',
ignore: ['node_modules'],
urlPrefix: '~/_next',
- release: options.buildId,
+ release: COMMIT_SHA,
})
)
}
diff --git a/examples/with-sentry/pages/_app.js b/examples/with-sentry/pages/_app.js
index 93e2a2a412c5c..4a3037ce39baa 100644
--- a/examples/with-sentry/pages/_app.js
+++ b/examples/with-sentry/pages/_app.js
@@ -1,9 +1,11 @@
import * as Sentry from '@sentry/node'
-Sentry.init({
- enabled: process.env.NODE_ENV === 'production',
- dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
-})
+if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
+ Sentry.init({
+ enabled: process.env.NODE_ENV === 'production',
+ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
+ })
+}
export default function App({ Component, pageProps, err }) {
// Workaround for https://github.com/vercel/next.js/issues/8592
diff --git a/examples/with-sentry/pages/_error.js b/examples/with-sentry/pages/_error.js
index 76a72693d4672..0b38c8d7b7776 100644
--- a/examples/with-sentry/pages/_error.js
+++ b/examples/with-sentry/pages/_error.js
@@ -1,12 +1,14 @@
import NextErrorComponent from 'next/error'
import * as Sentry from '@sentry/node'
-const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
+const MyError = async ({ statusCode, hasGetInitialPropsRun, err }) => {
if (!hasGetInitialPropsRun && err) {
// getInitialProps is not called in case of
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
Sentry.captureException(err)
+ // flush is needed after calling captureException to send server side errors to Sentry, otherwise the serverless function will exit before it's sent
+ await Sentry.flush(2000)
}
return
@@ -41,6 +43,7 @@ MyError.getInitialProps = async ({ res, err, asPath }) => {
}
if (err) {
Sentry.captureException(err)
+ await Sentry.flush(2000)
return errorInitialProps
}
@@ -50,6 +53,7 @@ MyError.getInitialProps = async ({ res, err, asPath }) => {
Sentry.captureException(
new Error(`_error.js getInitialProps missing data at path: ${asPath}`)
)
+ await Sentry.flush(2000)
return errorInitialProps
}
diff --git a/examples/with-sitemap/.env b/examples/with-sitemap/.env
new file mode 100644
index 0000000000000..8d8ccb6fca0e4
--- /dev/null
+++ b/examples/with-sitemap/.env
@@ -0,0 +1,2 @@
+# Used to add the domain to sitemap.xml, replace it with a real domain in production
+WEBSITE_URL=http://localhost:3000
\ No newline at end of file
diff --git a/examples/with-sitemap/README.md b/examples/with-sitemap/README.md
new file mode 100644
index 0000000000000..a6d6d7b56b76b
--- /dev/null
+++ b/examples/with-sitemap/README.md
@@ -0,0 +1,51 @@
+# With Sitemap example
+
+This example shows how to generate a `sitemap.xml` file based on the pages in your [Next.js](https://nextjs.org/) app. The sitemap will be generated and saved in the `public` directory after starting the development server or by making a build.
+
+## Deploy your own
+
+Deploy the example using [Vercel](https://vercel.com):
+
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/hello-world)
+
+## How to use
+
+### Using `create-next-app`
+
+Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
+
+```bash
+npx create-next-app --example with-sitemap with-sitemap-app
+# or
+yarn create next-app --example with-sitemap with-sitemap-app
+```
+
+### Download manually
+
+Download the example:
+
+```bash
+curl https://codeload.github.com/vercel/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-sitemap
+cd with-sitemap
+```
+
+Install it and run:
+
+```bash
+npm install
+npm run dev
+# or
+yarn
+yarn dev
+```
+
+Your app should be up and running on [http://localhost:3000](http://localhost:3000) and the sitemap should now be available in [http://localhost:3000/sitemap.xml](http://localhost:3000/sitemap.xml)! If it doesn't work, post on [GitHub discussions](https://github.com/vercel/next.js/discussions).
+
+To change the website URL used by `sitemap.xml`, open the file `.env` and change the `WEBSITE_URL` environment variable:
+
+```bash
+# Used to add the domain to sitemap.xml, replace it with a real domain in production
+WEBSITE_URL=https://my-domain.com
+```
+
+Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
diff --git a/examples/with-sitemap/next.config.js b/examples/with-sitemap/next.config.js
new file mode 100644
index 0000000000000..08a972d01c6d6
--- /dev/null
+++ b/examples/with-sitemap/next.config.js
@@ -0,0 +1,9 @@
+module.exports = {
+ webpack: (config, { isServer }) => {
+ if (isServer) {
+ require('./scripts/generate-sitemap')
+ }
+
+ return config
+ },
+}
diff --git a/examples/with-sitemap/package.json b/examples/with-sitemap/package.json
new file mode 100644
index 0000000000000..beb83580fa2e2
--- /dev/null
+++ b/examples/with-sitemap/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "with-sitemap",
+ "version": "0.1.0",
+ "scripts": {
+ "dev": "next dev",
+ "build": "next build",
+ "start": "next start"
+ },
+ "dependencies": {
+ "next": "latest",
+ "react": "^16.13.1",
+ "react-dom": "^16.13.1"
+ },
+ "devDependencies": {
+ "globby": "^11.0.1"
+ },
+ "license": "MIT"
+}
diff --git a/examples/with-sitemap/pages/contact.js b/examples/with-sitemap/pages/contact.js
new file mode 100644
index 0000000000000..0d718f02d5fc9
--- /dev/null
+++ b/examples/with-sitemap/pages/contact.js
@@ -0,0 +1,128 @@
+import Head from 'next/head'
+
+export default function Home() {
+ return (
+
+ )
+}
diff --git a/examples/with-sitemap/public/favicon.ico b/examples/with-sitemap/public/favicon.ico
new file mode 100644
index 0000000000000..4965832f2c9b0
Binary files /dev/null and b/examples/with-sitemap/public/favicon.ico differ
diff --git a/examples/with-sitemap/public/sitemap.xml b/examples/with-sitemap/public/sitemap.xml
new file mode 100644
index 0000000000000..73774003a77ab
--- /dev/null
+++ b/examples/with-sitemap/public/sitemap.xml
@@ -0,0 +1,10 @@
+
+
+ http://localhost:3000/contact
+ hourly
+
+
+ http://localhost:3000
+ hourly
+
+
\ No newline at end of file
diff --git a/examples/with-sitemap/public/vercel.svg b/examples/with-sitemap/public/vercel.svg
new file mode 100644
index 0000000000000..fbf0e25a651c2
--- /dev/null
+++ b/examples/with-sitemap/public/vercel.svg
@@ -0,0 +1,4 @@
+
\ No newline at end of file
diff --git a/examples/with-sitemap/scripts/generate-sitemap.js b/examples/with-sitemap/scripts/generate-sitemap.js
new file mode 100644
index 0000000000000..4bd49377b2c50
--- /dev/null
+++ b/examples/with-sitemap/scripts/generate-sitemap.js
@@ -0,0 +1,28 @@
+const fs = require('fs')
+const globby = require('globby')
+
+function addPage(page) {
+ const path = page.replace('pages', '').replace('.js', '').replace('.mdx', '')
+ const route = path === '/index' ? '' : path
+
+ return `
+ ${`${process.env.WEBSITE_URL}${route}`}
+ hourly
+ `
+}
+
+async function generateSitemap() {
+ // Ignore Next.js specific files (e.g., _app.js) and API routes.
+ const pages = await globby([
+ 'pages/**/*{.js,.mdx}',
+ '!pages/_*.js',
+ '!pages/api',
+ ])
+ const sitemap = `
+${pages.map(addPage).join('\n')}
+`
+
+ fs.writeFileSync('public/sitemap.xml', sitemap)
+}
+
+generateSitemap()
diff --git a/package.json b/package.json
index 661cb0b35b35d..0e6df064ec978 100644
--- a/package.json
+++ b/package.json
@@ -112,8 +112,8 @@
"release": "6.0.1",
"request-promise-core": "1.1.2",
"rimraf": "2.6.3",
- "selenium-standalone": "6.17.0",
- "selenium-webdriver": "4.0.0-alpha.5",
+ "selenium-standalone": "6.18.0",
+ "selenium-webdriver": "4.0.0-alpha.7",
"shell-quote": "1.7.2",
"styled-components": "5.1.0",
"styled-jsx-plugin-postcss": "2.0.1",
diff --git a/packages/create-next-app/README.md b/packages/create-next-app/README.md
index ad7d9fce6ea76..98ff887a14504 100644
--- a/packages/create-next-app/README.md
+++ b/packages/create-next-app/README.md
@@ -1,8 +1,30 @@
-# create-next-app
+# Create Next App
-This package includes the global command for creating [Next.js](https://github.com/vercel/next.js) applications.
+The easiest way to get started with Next.js is by using `create-next-app`. This simple CLI tool enables you to quickly start building a new Next.js application, with everything set up for you. You can create a new app using the default Next.js template, or by using one of the [official Next.js examples](https://github.com/vercel/next.js/tree/canary/examples). To get started, use the following command:
-Please refer to its documentation:
+```bash
+npx create-next-app
+```
-- [Setup](https://nextjs.org/docs/getting-started#setup) – How to create a new Next.js application.
-- [Documentation](https://nextjs.org/docs) – How to develop Next.js applications.
+To create a new app in a specific folder, you can send a name as an argument. For example, the following command will create a new Next.js app called `blog-app` in a folder with the same name:
+
+```bash
+npx create-next-app blog-app
+```
+
+## Options
+
+`create-next-app` comes with the following options:
+
+- **-e, --example [name]|[github-url]** - An example to bootstrap the app with. You can use an example name from the [Next.js repo](https://github.com/vercel/next.js/tree/master/examples) or a GitHub URL. The URL can use any branch and/or subdirectory.
+- **--example-path <path-to-example>** - In a rare case, your GitHub URL might contain a branch name with a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar). In this case, you must specify the path to the example separately: `--example-path foo/bar`
+
+## Why use Create Next App?
+
+`create-next-app` allows you to create a new Next.js app within seconds. It is officially maintained by the creators of Next.js, and includes a number of benefits:
+
+- **Interactive Experience**: Running `npx create-next-app` (with no arguments) launches an interactive experience that guides you through setting up a project.
+- **Zero Dependencies**: Initializing a project is as quick as one second. Create Next App has zero dependencies.
+- **Offline Support**: Create Next App will automatically detect if you're offline and bootstrap your project using your local package cache.
+- **Support for Examples**: Create Next App can bootstrap your application using an example from the Next.js examples collection (e.g. `npx create-next-app --example api-routes`).
+- **Tested**: The package is part of the Next.js monorepo and tested using the same integration test suite as Next.js itself, ensuring it works as expected with every release.
diff --git a/packages/next/README.md b/packages/next/README.md
index 9a401f10e64b7..560d19627a134 100644
--- a/packages/next/README.md
+++ b/packages/next/README.md
@@ -21,7 +21,11 @@ Visit https://next
## Documentation
-Visit https://nextjs.org/docs to view the documentation.
+Visit [https://nextjs.org/docs](https://nextjs.org/docs) to view the full documentation.
+
+## Who is using Next.js?
+
+Next.js is used by the world's leading companies. Check out the [Next.js Showcase](https://nextjs.org/showcase) to learn more.
## Contributing
diff --git a/packages/next/next-server/lib/router/router.ts b/packages/next/next-server/lib/router/router.ts
index 56e5fa0efda50..1e256d190aac2 100644
--- a/packages/next/next-server/lib/router/router.ts
+++ b/packages/next/next-server/lib/router/router.ts
@@ -802,28 +802,27 @@ export default class Router implements BaseRouter {
* @param url the href of prefetched page
* @param asPath the as path of the prefetched page
*/
- prefetch(
+ async prefetch(
url: string,
asPath: string = url,
options: PrefetchOptions = {}
): Promise {
- return new Promise((resolve, reject) => {
- const parsed = tryParseRelativeUrl(url)
+ const parsed = tryParseRelativeUrl(url)
- if (!parsed) return
+ if (!parsed) return
- const { pathname } = parsed
+ const { pathname } = parsed
- // Prefetch is not supported in development mode because it would trigger on-demand-entries
- if (process.env.NODE_ENV !== 'production') {
- return
- }
- const route = removePathTrailingSlash(pathname)
- Promise.all([
- this.pageLoader.prefetchData(url, asPath),
- this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),
- ]).then(() => resolve(), reject)
- })
+ // Prefetch is not supported in development mode because it would trigger on-demand-entries
+ if (process.env.NODE_ENV !== 'production') {
+ return
+ }
+
+ const route = removePathTrailingSlash(pathname)
+ await Promise.all([
+ this.pageLoader.prefetchData(url, asPath),
+ this.pageLoader[options.priority ? 'loadPage' : 'prefetch'](route),
+ ])
}
async fetchComponent(route: string): Promise {
diff --git a/packages/next/next-server/lib/router/utils/route-regex.ts b/packages/next/next-server/lib/router/utils/route-regex.ts
index b0f74bef7480a..be5c3865e2da7 100644
--- a/packages/next/next-server/lib/router/utils/route-regex.ts
+++ b/packages/next/next-server/lib/router/utils/route-regex.ts
@@ -107,7 +107,7 @@ export function getRouteRegex(
.join('')
return {
- re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'),
+ re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
groups,
routeKeys,
namedRegex: `^${namedParameterizedRoute}(?:/)?$`,
@@ -115,7 +115,7 @@ export function getRouteRegex(
}
return {
- re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'),
+ re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
groups,
}
}
diff --git a/packages/next/package.json b/packages/next/package.json
index bada05e57c3a2..3004bc9753eba 100644
--- a/packages/next/package.json
+++ b/packages/next/package.json
@@ -107,7 +107,7 @@
"use-subscription": "1.4.1",
"watchpack": "2.0.0-beta.13",
"web-vitals": "0.2.1",
- "webpack": "4.43.0",
+ "webpack": "4.44.0",
"webpack-sources": "1.4.3"
},
"peerDependencies": {
diff --git a/run-tests.js b/run-tests.js
index df5991493e6f4..c37091b807d66 100644
--- a/run-tests.js
+++ b/run-tests.js
@@ -136,7 +136,7 @@ const TIMINGS_API = `https://next-timings.jjsweb.site/api/timings`
{
stdio: 'inherit',
env: {
- JEST_RETRY_TIMES: 3,
+ JEST_RETRY_TIMES: 0,
...process.env,
...(isAzure
? {
diff --git a/test/integration/amphtml/pages/only-amp.js b/test/integration/amphtml/pages/only-amp.js
index 653dbecd541d5..41866b35c52c3 100644
--- a/test/integration/amphtml/pages/only-amp.js
+++ b/test/integration/amphtml/pages/only-amp.js
@@ -1,7 +1,9 @@
export const config = { amp: true }
-export default () => (
-