How can I convert this nextjs app from using the SRC directory to using just the APP directory and the root folder structure if we want to use best practices for nextjs14 and beyond.
GitHub Copilot: Deciding which workspace information to collect
Collecting workspace information
Filtering to most relevant information
To convert your Next.js app from using the src
directory to using just the app
directory and the root folder structure, you can follow these steps:
- Move all the files and folders from
src
to theapp
directory. This includesauth.ts
,components
,db
,lib
,types
, and any other files or folders you may have insrc
. - Update all the import paths in your project to reflect the new structure. For example, if you have an import like this in your code:
import { db } from "./src/db/index";
You should change it to:
import { db } from "./app/db/index";
- Update your
tsconfig.json
file to include theapp
directory in theinclude
array:
{
"include": ["app/**/*"],
// rest of your tsconfig.json
}
- Update your
next.config.js
file to include theapp
directory in thedir
option:
const nextConfig = {
dir: "./app",
// rest of your next.config.js
};
- Update your scripts in
package.json
to point to theapp
directory. For example, if you have a script like this:
"dev": "next dev src"
You should change it to:
"dev": "next dev app"
- Finally, test your application to make sure everything is working as expected. You can do this by running your development server with
npm run dev
(oryarn dev
,pnpm dev
,bun dev
depending on your package manager) and navigating tohttp://localhost:3000
in your browser.
Remember to commit your changes to version control after verifying that everything works as expected.