r/reactjs • u/Nutlope • Oct 25 '22
Next.js 13: Layouts, React Server Components (async/await), Streaming
https://nextjs.org/blog/next-133
u/Aegis8080 NextJS App Router Oct 26 '22
I'm more interested in the new app folder structure and server components.
My only questions are
Where do we place the
_appand_documentfiles now?I can't turn components that are using CSS-in-JS (e.g., Emotion) into server components right, since they need hydration to function?
5
u/Aegis8080 NextJS App Router Oct 26 '22
Answering my own questions, for Q2, it is answered here: https://beta.nextjs.org/docs/styling/css-in-js
Basically, none of the CSS-in-JS libraries support server components yet, and most of them (a noticeable example is Emotion) don't even work with the
appdirectory at all.3
u/rmyworld Oct 26 '22
_app.jsand_document.jsare nowlayout.js. Though, I think what is not being discussed is wherepages/apiis going. Testing the latest NextJS template right now, it looks likeappfolder does not support it.4
u/Aegis8080 NextJS App Router Oct 26 '22
pages/apiis staying where it is, given the example of OG image generation is making use of that.1
2
u/nerdy_adventurer Oct 26 '22 edited Oct 26 '22
Does anyone known how to achieve following Gatsby features in Nextjs
Incremental builds
Data layer
Unified GraphQL graph
I am not much fan of SSR, since Cloudflare recently announced Nextjs edge support I am interested in migrating.
Also anything similar to partial hydration in Nextjs since Gatsby v5 is having it?
2
u/LeKoArts Oct 27 '22
Use Gatsby 😉
1
u/nerdy_adventurer Nov 02 '22
Some current issues with Gatsby
things like DSG are coupled to Gatsby Cloud (where we use CF pages)
No edge support yet
Slow dev server
Other than that Gatsby with GraphQL is great for us.
1
1
u/Aegis8080 NextJS App Router Oct 26 '22
I'm not too sure about @next/font. How is that different from Fontsource?
Also currently, if people are using CSS-in-JS libraries, the font styles may be injected AFTER the CSS-in-JS styles, hence unable to use custom fonts.
1
u/rantow Oct 26 '22
Anyone know if there is a way to have multiple layouts at the root?
I would like to have my auth routes (/login, /forgot-password, /register, etc) have a different layout to pages like /dashboard, /settings without having to separate them from / into their own base segments like /auth/login, /auth/forgot-password and /app/dashboard /app/settings
2
1
23
u/m1around Oct 25 '22
On the page, about halfway down there's a Data Fetching section.
In there, they have this example react code:
Anyone know what the `use` import is? Some kind of meta-hook for data fetching??