2019-12-23 16:07:38 +01:00
---
2020-01-03 19:16:51 +01:00
description: Get started with Next.js in the official documentation, and learn more about all our features!
2019-12-23 16:07:38 +01:00
---
2022-11-02 18:25:16 +01:00
> Next.js 13 was recently released, [learn more](https://nextjs.org/blog/next-13) and see the [upgrade guide](https://nextjs.org/docs/upgrading#upgrading-from-12-to-13). Version 13 also introduces beta features like the [`app` directory](https://beta.nextjs.org/docs/app-directory-roadmap) that works alongside the `pages` directory (stable) for incremental adoption. You can continue using `pages` in Next.js 13, but if you want to try the new `app` features, [see the new beta docs](https://beta.nextjs.org/docs).
2022-10-31 16:29:45 +01:00
2019-12-23 16:07:38 +01:00
# Getting Started
Welcome to the Next.js documentation!
2022-10-31 16:29:45 +01:00
If you're new to Next.js, we recommend starting with the [learn course ](https://nextjs.org/learn/basics/create-nextjs-app ). The interactive course with quizzes will guide you through everything you need to know to use Next.js.
2019-12-23 16:07:38 +01:00
2020-05-27 23:51:11 +02:00
If you have questions about anything related to Next.js, you're always welcome to ask our community on [GitHub Discussions ](https://github.com/vercel/next.js/discussions ).
2020-03-25 16:06:58 +01:00
2019-12-23 16:07:38 +01:00
#### System Requirements
2023-04-28 17:07:54 +02:00
- [Node.js 16.8.0 ](https://nodejs.org/ ) or newer
2019-12-23 16:07:38 +01:00
- MacOS, Windows (including WSL), and Linux are supported
2022-02-13 04:03:25 +01:00
## Automatic Setup
2019-12-23 16:07:38 +01:00
2022-11-22 15:11:55 +01:00
We recommend creating a new Next.js app using `create-next-app` , which sets up everything automatically for you. (You don't need to create an empty directory. `create-next-app` will make one for you.) To create a project, run:
2020-02-12 21:19:58 +01:00
```bash
2021-10-04 11:13:45 +02:00
npx create-next-app@latest
2020-02-12 21:19:58 +01:00
# or
yarn create next-app
2022-03-30 23:03:21 +02:00
# or
pnpm create next-app
2020-02-12 21:19:58 +01:00
```
2021-05-07 10:08:16 +02:00
If you want to start with a TypeScript project you can use the `--typescript` flag:
```bash
2021-10-04 11:13:45 +02:00
npx create-next-app@latest --typescript
2021-05-07 10:08:16 +02:00
# or
yarn create next-app --typescript
2022-05-27 23:21:40 +02:00
# or
pnpm create next-app --typescript
2021-05-07 10:08:16 +02:00
```
2021-12-06 23:37:02 +01:00
After the installation is complete:
2022-04-06 15:06:50 +02:00
- Run `npm run dev` or `yarn dev` or `pnpm dev` to start the development server on `http://localhost:3000`
2022-02-06 05:21:35 +01:00
- Visit `http://localhost:3000` to view your application
- Edit `pages/index.js` and see the updated result in your browser
2020-02-12 21:19:58 +01:00
2022-02-06 05:21:35 +01:00
For more information on how to use `create-next-app` , you can review the [`create-next-app` documentation ](/docs/api-reference/create-next-app.md ).
2020-08-03 15:43:16 +02:00
2020-02-12 21:19:58 +01:00
## Manual Setup
2019-12-23 16:07:38 +01:00
Install `next` , `react` and `react-dom` in your project:
```bash
2020-01-27 14:35:12 +01:00
npm install next react react-dom
2020-08-28 04:27:34 +02:00
# or
yarn add next react react-dom
2022-04-06 15:06:50 +02:00
# or
pnpm add next react react-dom
2019-12-23 16:07:38 +01:00
```
2020-01-07 20:37:19 +01:00
Open `package.json` and add the following `scripts` :
2019-12-23 16:07:38 +01:00
```json
"scripts": {
2020-07-30 20:44:44 +02:00
"dev": "next dev",
2019-12-23 16:07:38 +01:00
"build": "next build",
2021-06-03 14:01:24 +02:00
"start": "next start",
"lint": "next lint"
2019-12-23 16:07:38 +01:00
}
```
These scripts refer to the different stages of developing an application:
2022-04-06 15:06:50 +02:00
- `dev` - Runs [`next dev` ](/docs/api-reference/cli.md#development ) to start Next.js in development mode
- `build` - Runs [`next build` ](/docs/api-reference/cli.md#build ) to build the application for production usage
- `start` - Runs [`next start` ](/docs/api-reference/cli.md#production ) to start a Next.js production server
- `lint` - Runs [`next lint` ](/docs/api-reference/cli.md#lint ) to set up Next.js' built-in ESLint configuration
Create two directories `pages` and `public` at the root of your application:
2019-12-23 16:07:38 +01:00
2023-01-26 02:25:42 +01:00
- `pages` - Associated with a route based on their file name. For example, `pages/about.js` is mapped to `/about`
2022-04-06 15:06:50 +02:00
- `public` - Stores static assets such as images, fonts, etc. Files inside `public` directory can then be referenced by your code starting from the base URL (`/`).
2019-12-23 16:07:38 +01:00
2023-04-03 09:43:34 +02:00
Next.js is built around the concept of [pages ](/docs/basic-features/pages.md ). A page is a [React Component ](https://react.dev/learn/your-first-component ) exported from a `.js` , `.jsx` , `.ts` , or `.tsx` file in the `pages` directory. You can even add [dynamic route ](/docs/routing/dynamic-routes ) parameters with the filename.
2019-12-23 16:07:38 +01:00
2023-01-26 02:25:42 +01:00
Inside the `pages` directory, add the `index.js` file to get started. This is the page that is rendered when the user visits the root of your application.
2019-12-23 16:07:38 +01:00
2022-04-06 15:06:50 +02:00
Populate `pages/index.js` with the following contents:
2019-12-23 16:07:38 +01:00
```jsx
function HomePage() {
return < div > Welcome to Next.js!< / div >
}
export default HomePage
```
2022-04-06 15:06:50 +02:00
After the set up is complete:
- Run `npm run dev` or `yarn dev` or `pnpm dev` to start the development server on `http://localhost:3000`
- Visit `http://localhost:3000` to view your application
- Edit `pages/index.js` and see the updated result in your browser
2019-12-23 16:07:38 +01:00
So far, we get:
2022-02-13 04:03:25 +01:00
- Automatic compilation and [bundling ](/docs/advanced-features/compiler.md )
2020-05-22 04:40:06 +02:00
- [React Fast Refresh ](https://nextjs.org/blog/next-9-4#fast-refresh )
2022-04-06 15:06:50 +02:00
- [Static generation and server-side rendering ](/docs/basic-features/data-fetching/overview.md ) of [`pages/` ](/docs/basic-features/pages.md )
- [Static file serving ](/docs/basic-features/static-file-serving.md ) through `public/` which is mapped to the base URL (`/`)
2019-12-23 16:07:38 +01:00
2022-02-13 04:03:25 +01:00
In addition, any Next.js application is ready for production from the start. Read more in our [Deployment documentation ](/docs/deployment.md ).
2020-05-22 04:40:06 +02:00
2019-12-23 16:07:38 +01:00
## Related
For more information on what to do next, we recommend the following sections:
< div class = "card" >
< a href = "/docs/basic-features/pages.md" >
< b > Pages:< / b >
2020-01-20 21:40:20 +01:00
< small > Learn more about what pages are in Next.js.< / small >
2019-12-23 16:07:38 +01:00
< / a >
< / div >
< div class = "card" >
< a href = "/docs/basic-features/built-in-css-support.md" >
< b > CSS Support:< / b >
2022-02-13 04:03:25 +01:00
< small > Built-in CSS support to add custom styles to your app.< / small >
2019-12-23 16:07:38 +01:00
< / a >
< / div >
2020-04-24 23:29:26 +02:00
< div class = "card" >
< a href = "/docs/api-reference/cli.md" >
< b > CLI:< / b >
< small > Learn more about the Next.js CLI.< / small >
< / a >
< / div >