Aimed at modules like @next/mdx, which adds support for pages ending with .mdx
. You can configure the extensions looked for in the pages
directory when resolving pages.
Open next.config.js
and add the pageExtensions
config:
module.exports = {
pageExtensions: ['mdx', 'jsx', 'js', 'ts', 'tsx'],
}
Note: configuring
pageExtensions
also affects_document.js
,_app.js
as well as files underpages/api/
. For example, settingpageExtensions: ['page.tsx', 'page.ts']
means the following files:_document.tsx
,_app.tsx
,pages/users.tsx
andpages/api/users.ts
will have to be renamed to_document.page.tsx
,_app.page.tsx
,pages/users.page.tsx
andpages/api/users.page.ts
respectively.