Unable to render when using with NextJS v13 & React Server Components
See original GitHub issueDescribe the bug
App does not render when I import a .css.ts
file in a React Server Component. See component in repro repo.
Workaround is to convert the .css.ts
to a default export and use swc-plugin-vanilla-extract instead of @vanilla-extract/next-plugin
// page.css.ts before
export const container = style({
background: 'blue'
})
// page.css.ts workaround
const container = style({
background: 'blue'
})
export default {
container
}
Reproduction
https://github.com/nick-kang/vanilla-extract-repro-001
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
Memory: 29.65 GB / 46.75 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 18.7.0 - /run/user/1000/fnm_multishells/553958_1669586582142/bin/node
Yarn: 3.2.2 - /run/user/1000/fnm_multishells/553958_1669586582142/bin/yarn
npm: 8.15.0 - /run/user/1000/fnm_multishells/553958_1669586582142/bin/npm
Watchman: 2022.07.04.00 - /home/linuxbrew/.linuxbrew/bin/watchman
Browsers:
Chrome: 107.0.5304.121
Firefox: 107.0
npmPackages:
@vanilla-extract/css: ^1.9.2 => 1.9.2
@vanilla-extract/next-plugin: ^2.1.1 => 2.1.1
@vanilla-extract/webpack-plugin: ^2.2.0 => 2.2.0
Used Package Manager
pnpm
Logs
TypeError: Cannot read properties of undefined (reading 'chunks')
at getCssInlinedLinkTags (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:362:49)
at createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:630:52)
at /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:753:62
at Array.map (<anonymous>)
at createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:717:84)
at /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:753:62
at Array.map (<anonymous>)
at createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:717:84)
at /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:753:62
at Array.map (<anonymous>)
at createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:717:84)
at /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:753:62
at Array.map (<anonymous>)
at createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:717:84)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:753:56
at async Promise.all (index 0)
at async createComponentTree (/node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:717:38)
at async /node_modules/.pnpm/next@13.0.5_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render.js:993:51
### Validations
- [X] Check that there isn't [already an issue](https://github.com/vanilla-extract-css/vanilla-extract/issues) that reports the same bug to avoid creating a duplicate.
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:11
- Comments:9
Top Results From Across the Web
Next.js 13 support (server-side components) #3707 - GitHub
Bug Report Unable to use @adobe/react-spectrum with Next.js 13. ... for server-side component support is to use client-side rendering.
Read more >Rendering: Server and Client Components - Next.js beta docs
This page will go through the differences between Server and Client Components and how to use them in your Next.js application.
Read more >React Server vs Client components in Next.js 13 - Ankita
They can't use React life cycle hooks; It will make sense if you start thinking of React components like the backend. Examples of...
Read more >Fun With Next.js 13 Server Components - DEV Community
I.e., the rendering happens and only happens on the server side, even if the loading of the component is triggered on the client...
Read more >Next.js 13 - Server & Client Component Basics - YouTube
In this video, we'll be learning about Next.js 13 server & client component basics. Next.js is a powerful JavaScript library that lets us ......
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
Alternative workaround: two small patches for NextJS + VE NextJS plugin: https://gist.github.com/bizarre/825cab8224c28e93ff1a3933642f9271 (use with patch-package).
Only caveat I’ve found so far is that
globalStyle
doesn’t seem to actually be global for server components, otherwise works pretty well.Is maintainers of this library planning to support Next.js 13 (appDir) and React Server Component?