Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
Next/13/App Directory Boilerplate
Last update
Jan 10, 2025
The first step to migrate your pages to the app directory is to provide a new file structure, respected by the App router.
This is attempted by this codemod, which reads the contents of your pages directory and creates the placeholder files.
The placeholder files define the basic layout and page structure.
The boilerplate includes the following:
- placeholder
page.tsxandlayout.tsxfiles which define a UI unique to a route. - the placeholder
app/layout.tsxfile which replacespages/_app.tsxandpages/_document.tsxfiles. - the placeholder
error.tsxfile which replacespages/_error.tsxfiles. - the placeholder
not-found.tsxfile which replacespages/404.tsxfiles.
If the codemod detects that a getStaticProps function is not used, it will be removed. Otherwise, it will remove the export keyword from the function definition.
Example
If you have the following directory:
pages├── _app.tsx├── _document.tsx├── _error.tsx├── 404.tsx├── a.tsx└── b└── c.tsx
The codemod will generate the following corresponding directory:
app├── page.tsx├── layout.tsx├── error.tsx├── not-found.tsx├── a└── page.tsx└── b└── c└── page.tsx
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community