Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
create-next-app
Advanced tools
The create-next-app npm package is a command-line tool that allows you to quickly set up a new Next.js project with a default configuration. It simplifies the process of bootstrapping a Next.js application by providing a pre-configured project structure, dependencies, and scripts.
Bootstrap a New Next.js Project
This command initializes a new Next.js project in a directory named 'my-next-app'. It sets up the project with a default configuration, including necessary dependencies and scripts.
npx create-next-app@latest my-next-app
Use a Custom Template
This command initializes a new Next.js project using a custom template. In this example, the 'blog-starter' template is used to set up a blog application with pre-configured settings and components.
npx create-next-app@latest my-next-app --example blog-starter
TypeScript Support
This command initializes a new Next.js project with TypeScript support. It sets up the necessary TypeScript configuration and dependencies, allowing you to write your application in TypeScript from the start.
npx create-next-app@latest my-next-app --typescript
Create React App is a similar tool for bootstrapping React applications. It provides a default project structure, configuration, and scripts for building React applications. While create-next-app is tailored for Next.js, which includes server-side rendering and static site generation, Create React App is focused on client-side rendering.
Vue CLI is a command-line tool for scaffolding Vue.js projects. It offers a similar experience to create-next-app but for Vue.js applications. Vue CLI provides a range of templates and plugins to customize the project setup, whereas create-next-app is specifically designed for Next.js.
Angular CLI is a command-line interface for Angular applications. It helps in setting up a new Angular project with a default configuration, similar to create-next-app for Next.js. Angular CLI includes features like code generation, testing, and deployment, tailored for Angular applications.
The easiest way to create a React app with server-side rendering thanks to Next.js
Getting Started · Starting from scratch with Create Next App · Starting from Next.js Examples
If you run into any issues or have feedback, please file an issue
npx & npm (Node 8.x.x+) | yarn create (Yarn 1.0.0+) | manual install (Node 6.x.x+) | |
---|---|---|---|
1. | npx create-next-app my-app | yarn create next-app my-app | npm install -g create-next-app |
2. | cd my-app/ | cd my-app/ | create-next-app my-app |
3. | npm run dev | yarn dev | cd my-app/ |
4. | npm run dev |
Open http://localhost:3000 to view your running app.
When you're ready for production, run the build
then start
scripts.
You don't need to install or setup Webpack or Babel.
They come packaged with next
, so you can just start coding.
After running create-next-app
, you're good to go!
Follow the steps in the above table:
Minimum Requirements:
You don't need to use Node as your primary backend. The Node installation is only required for Create Next App and running the Next.js server in development/production.
create-next-app
will have created a directory called my-app
inside the current folder. Inside that directory, it will generate the initial project structure and install necessary dependencies:
.
├── README.md
├── components
│ ├── head.js
│ └── nav.js
├── next.config.js
├── node_modules
│ ├── [...]
├── package.json
├── pages
│ └── index.js
├── static
│ └── favicon.ico
└── yarn.lock
Routing in Next.js is based on the file system, so ./pages/index.js
maps to the /
route and
./pages/about.js
would map to /about
.
The ./static
directory maps to /static
in the next
server, so you can put all your
other static resources like images or compiled CSS in there.
Out of the box, we get:
./pages
./static/
is mapped to /static/
Once the installation is finished, you can run some commands in your project:
npm run dev
or yarn dev
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any errors in the console.
npm run build
or yarn build
Builds the app for production to the .next
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
npm run start
or yarn start
Starts the application in production mode. The application should be compiled with `npm run build` first.
Now you're ready to code & deploy your app!
There are a ton of examples in the Next.js repo (and growing!) that you can use to bootstrap your app.
To use an example:
basic-css
)create-next-app --example basic-css example-app
It is worth noting that the basic-css example above uses styled-jsx.
We are grateful to the authors of existing related projects for their ideas as inspiration:
Looking for alternatives? Here are some other project starter kits:
Questions? Feedback? Please let us know
This repo, create-next-app
, was previously maintiained by Segment, Inc. It is now maintained by ZEIT, Inc.
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
Copyright (c) 2017-present Segment.io, Inc. friends@segment.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Create Next.js-powered React apps with one command
The npm package create-next-app receives a total of 129,225 weekly downloads. As such, create-next-app popularity was classified as popular.
We found that create-next-app demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.