pageExtensions
Last updated April 15, 2025
You can extend the default Page extensions (.tsx,.ts,.jsx,.js) used by Next.js. Insidenext.config.js, add thepageExtensions config:
next.config.js
module.exports= { pageExtensions: ['mdx','md','jsx','js','tsx','ts'],}Changing these values affectsall Next.js pages, including the following:
proxy.jsinstrumentation.jspages/_document.jspages/_app.jspages/api/
For example, if you reconfigure.ts page extensions to.page.ts, you would need to rename pages likeproxy.page.ts,instrumentation.page.ts,_app.page.ts.
Including non-page files in thepages directory
You can colocate test files or other files used by components in thepages directory. Insidenext.config.js, add thepageExtensions config:
next.config.js
module.exports= { pageExtensions: ['page.tsx','page.ts','page.jsx','page.js'],}Then, rename your pages to have a file extension that includes.page (e.g. renameMyPage.tsx toMyPage.page.tsx). Ensure you renameall Next.js pages, including the files mentioned above.
Was this helpful?