[Feature Request] Next.js custom server support
See original GitHub issueDesired Behavior
@nrwl/next would support the custom server and routing feature of Next.js. This inevitably ties in with #1895 as well.
Current Behavior
We are limited to modifying pages.
Context
nx report just returns with Project target does not exist., but:
- @nrwl/cli v8.6.0
- @nrwl/next v8.6.0
- @nrwl/workspace v8.6.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:24 (5 by maintainers)
Top Results From Across the Web
Advanced Features: Custom Server - Next.js
Start a Next.js app programmatically using a custom server.
Read more >Build a server-rendered React app with Next.js and Express
Using Express with Next.js, you can: Easily build web socket features in your applications; Develop custom or extra logic for your Next.js ......
Read more >Next.js on Netlify
Use redirects, middleware, custom headers and more to extend your Next.js ... Netlify supports Next.js internationalized routing functionality for ...
Read more >What's New in Next.js 13 - AppSignal Blog
It supports Server Components, TypeScript, JSX, CSS, and more. As the project is in alpha state, many of the features are not yet...
Read more >Deploying with Custom Serverless Next.js Routing - Vercel
This is an amazing feature of Next.js, however, it cannot control how the server routes to the app if the routes are not...
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 Free
Top 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

Hello 🖖
It seems Nx implemented
customServerPathon Next plugins. But I can’t make it working as I always getCouldn't find apagesdirectory. Please create one under the project rootMy
server.jsfile is located onapp/my-next-app/server.jsDoes anyone has encountered the same issue ?Thanks !
EDIT : I found the solution
If you want to use
customServerPathyou will have to export a function taking three args (as described in this file https://github.com/nrwl/nx/blob/master/packages/next/src/builders/server/lib/custom-server.ts) in a JS file and use the first arg as a NextJS server to callgetRequestHandleron it.It could be cool to have a bit more documentation about it on this page https://nx.dev/latest/react/plugins/next/executors/server
@zenVentzi this feature already is in (minus TypeScript support)
Here is an example of how to implement.
https://gist.github.com/stramel/57483a68559dca2c6471b3170a28042f