Receiving client error when using `pageExtensions` in next.config.js
See original GitHub issueHi @KATT, thank you and all the contributors for your hard work with this library. I am running into the following issue.
Issue
After cloning the examples-next-prisma-starter repo, and setting pageExtensions
in next.config.js, and running npm run dx
I receive the following error:
trpc version(s):
- “@trpc/client”: “^9.17.0”,
- “@trpc/next”: “^9.17.0”,
- “@trpc/react”: “^9.17.0”,
- “@trpc/server”: “^9.17.0”
How to replicate
- clone https://github.com/trpc/examples-next-prisma-starter
- update the next.config.js file to the following:
/**
* @link https://nextjs.org/docs/api-reference/next.config.js/introduction
* @type {import('next').NextConfig}
*/
const nextConfig = {
pageExtensions: ['page.tsx'],
reactStrictMode: true,
};
module.exports = nextConfig;
- Change the name of
pages/index.tsx
topages/index.page.tsx
- Start the application by running
npm run dx
- Navigate to the application in your browser
Note: I am adding the .page.
extension to my pages in order to have my .test files adjacent to my page files. Next attempts to build the test file unless I follow the fix posted here: https://www.reddit.com/r/nextjs/comments/lm0soy/any_way_to_omit_test_files_from_the_build_process/
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Custom Page Extensions - next.config.js
Extend the default page extensions used by Next.js when resolving pages in the pages directory. ... Inside next.config.js , add the pageExtensions config:...
Read more >pageExtensions not respecting file extension #6878 - GitHub
If I provide next.config.js a pageExtensions value of pageExtensions: ['tsx'] I am having pages created for non-tsx pages. To Reproduce.
Read more >Error of build because of the error Module parse failed
After the commannd npm run build I'm getting the following error. warn - Invalid next.config.js options detected: - The root value has an ......
Read more >8.0.3 - next - npm
jsonPageRes - Fetch Response object (client only); err - Error object if any error is encountered during the rendering. Routing. Next.js does ...
Read more >Development-only pages in Next.js - DEV Community
Build pages in Next.js that are only viewable in a development environment ... site by getting creative with Next's pageExtensions setting.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey there! Looking at the docs on next.js for this they have a note on there
Just tested it and adding
.page.tsx
to the following files:src/pages/_app.tsx
,src/pages/index.tsx
,src/pages/post/[id].tsx
and adding something likeapi.ts
to yourpageExtensions
so you can renamesrc/pages/api/trpc/[trpc].ts
to something like[trpc].api.ts
should solve this for you.Basically this 😃
@timcole Thanks! That did the trick.