@@ -124,7 +124,7 @@ Both `layout.tsx` and `page.tsx` will be rendered when the user visits the root
...
@@ -124,7 +124,7 @@ Both `layout.tsx` and `page.tsx` will be rendered when the user visits the root
> **Good to know**:
> **Good to know**:
>
>
> - If you forget to create the root layout, Next.js will automatically create this file when running the development server with `next dev`.
> - If you forget to create the root layout, Next.js will automatically create this file when running the development server with `next dev`.
> - You can optionally use a [`src` directory](/docs/app/building-your-application/configuring/src-directory) in the root of your project to separate your application's code from configuration files.
> - You can optionally use a [`src` folder](/docs/app/api-reference/file-conventions/src-folder) in the root of your project to separate your application's code from configuration files.
@@ -285,12 +285,12 @@ Route groups are useful for:
...
@@ -285,12 +285,12 @@ Route groups are useful for:
- [Creating multiple nested layouts in the same segment, including multiple root layouts](#creating-multiple-root-layouts)
- [Creating multiple nested layouts in the same segment, including multiple root layouts](#creating-multiple-root-layouts)
- [Adding a layout to a subset of routes in a common segment](#opting-specific-segments-into-a-layout)
- [Adding a layout to a subset of routes in a common segment](#opting-specific-segments-into-a-layout)
### `src` directory
### `src` folder
Next.js supports storing application code (including `app`) inside an optional [`src` directory](/docs/app/building-your-application/configuring/src-directory). This separates application code from project configuration files which mostly live in the root of a project.
Next.js supports storing application code (including `app`) inside an optional [`src` folder](/docs/app/api-reference/file-conventions/src-folder). This separates application code from project configuration files which mostly live in the root of a project.
<Image
<Image
alt="An example folder structure with the `src` directory"
alt="An example folder structure with the `src` folder"
description: Save pages under the `src` directory as an alternative to the root `pages` directory.
nav_title: src
description: Save pages under the `src` folder as an alternative to the root `pages` directory.
related:
related:
links:
links:
- app/getting-started/project-structure
- app/getting-started/project-structure
...
@@ -8,14 +9,14 @@ related:
...
@@ -8,14 +9,14 @@ related:
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
As an alternative to having the special Next.js `app` or `pages` directories in the root of your project, Next.js also supports the common pattern of placing application code under the `src` directory.
As an alternative to having the special Next.js `app` or `pages` directories in the root of your project, Next.js also supports the common pattern of placing application code under the `src` folder.
This separates application code from project configuration files which mostly live in the root of a project, which is preferred by some individuals and teams.
This separates application code from project configuration files which mostly live in the root of a project, which is preferred by some individuals and teams.
To use the `src` directory, move the `app` Router folder or `pages` Router folder to `src/app` or `src/pages` respectively.
To use the `src` folder, move the `app` Router folder or `pages` Router folder to `src/app` or `src/pages` respectively.
<Image
<Image
alt="An example folder structure with the `src` directory"
alt="An example folder structure with the `src` folder"
@@ -29,6 +30,6 @@ To use the `src` directory, move the `app` Router folder or `pages` Router folde
...
@@ -29,6 +30,6 @@ To use the `src` directory, move the `app` Router folder or `pages` Router folde
> - `.env.*` files should remain in the root of your project.
> - `.env.*` files should remain in the root of your project.
> - `src/app` or `src/pages` will be ignored if `app` or `pages` are present in the root directory.
> - `src/app` or `src/pages` will be ignored if `app` or `pages` are present in the root directory.
> - If you're using `src`, you'll probably also move other application folders such as `/components` or `/lib`.
> - If you're using `src`, you'll probably also move other application folders such as `/components` or `/lib`.
> - If you're using Middleware, ensure it is placed inside the `src` directory.
> - If you're using Middleware, ensure it is placed inside the `src` folder.
> - If you're using Tailwind CSS, you'll need to add the `/src` prefix to the `tailwind.config.js` file in the [content section](https://tailwindcss.com/docs/content-configuration).
> - If you're using Tailwind CSS, you'll need to add the `/src` prefix to the `tailwind.config.js` file in the [content section](https://tailwindcss.com/docs/content-configuration).
> - If you are using TypeScript paths for imports such as `@/*`, you should update the `paths` object in `tsconfig.json` to include `src/`.
> - If you are using TypeScript paths for imports such as `@/*`, you should update the `paths` object in `tsconfig.json` to include `src/`.
{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
{/* DO NOT EDIT. The content of this doc is generated from the source above. To edit the content of this page, navigate to the source page in your editor. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}