-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Maybe you saw it already that every NextJS project ships now with Relay support by default!
https://nextjs.org/blog/next-12-1

Basically it means that the swc version of the babel-plugin-relay is built in and can be configured directly in the next.js config:
// next.config.js
module.exports = {
compiler: {
relay: {
// This should match relay.config.js
src: './',
artifactDirectory: './__generated__',
language: 'typescript',
},
},
}NextJS does not provide a concept for splitting data loading into components. (beside from waterfall loading)
For me this makes Relay a perfect match for many medium-sized to large NextJS websites and applications.
NextJS got incredibly popular for its simplicity - unfortunately setting up Relay for NextJS is really hard.
It has been tried several times but most tries got abandoned after the POC phase:
- https://github.com/dgca/next-relay-bridge (allows to wait for critical requests during SSR but looks quite fragile and unmaintained)
- https://github.com/RevereCRE/relay-nextjs (probably the most advanced solution, however it doesn't allow waiting for critical requests during SSR, it doesn't support SSG, and it doesn't support concurrency mode)
- https://github.com/vercel/next.js/tree/canary/examples/with-relay-modern (part of the official next repository - not touched for 2 years, no typings, boilerplate code for every page e.g.:
environment.getStore().getSource().toJSON()...)
I believe this could be done better and I believe that if someone from the Relay team could invest time here to connect the power of Relays typesafe modular data loading with NextJs it might be a big push for Relays popularity and could help the entire ecosystem.