Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Important
Security Advisory: React2Shell & two new vulnerabilities
Find out more

src Directory

Last updated April 24, 2025

As an alternative to having the special Next.jsapp orpages directories in the root of your project, Next.js also supports the common pattern of placing application code under thesrc 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.

To use thesrc folder, move theapp Router folder orpages Router folder tosrc/app orsrc/pages respectively.

An example folder structure with the `src` folderAn example folder structure with the `src` folder

Good to know:

  • The/public directory should remain in the root of your project.
  • Config files likepackage.json,next.config.js andtsconfig.json should remain in the root of your project.
  • .env.* files should remain in the root of your project.
  • src/app orsrc/pages will be ignored ifapp orpages are present in the root directory.
  • If you're usingsrc, you'll probably also move other application folders such as/components or/lib.
  • If you're using Proxy, ensure it is placed inside thesrc folder.
  • If you're using Tailwind CSS, you'll need to add the/src prefix to thetailwind.config.js file in thecontent section.
  • If you are using TypeScript paths for imports such as@/*, you should update thepaths object intsconfig.json to includesrc/.

Was this helpful?

supported.

[8]ページ先頭

©2009-2025 Movatter.jp