stitchesjs / stitches

[Not Actively Maintained] CSS-in-JS with near-zero runtime, SSR, multi-variant support, and a best-in-class developer experience.
https://stitches.dev
MIT License
7.72k stars 251 forks source link

not working from next.js 13 & need server side supports for next.js 13 #1127

Open restareaByWeezy opened 1 year ago

restareaByWeezy commented 1 year ago

Bug report

I tried on next.js 13 app dir and it seems styling is not working.

I read the issue below and found couple of answers to figure it out example:

"use client"

import React from "react"
import { useServerInsertedHTML } from "next/navigation"
import { getCssText } from "../../stitches.config"

export function ServerStylesheet({ children }) {
  useServerInsertedHTML(() => {
    return <style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
  })

  return children
}

#1109

but still not working for me (even from client side). Any solutions suggested?

Nedilko commented 1 year ago

I successfully done with setting stitches with next13. Use hook useServerInsertedHTML

jvgreenaway commented 1 year ago

@Nedilko Do you have some example code - I can only get client-side style rendering to work.

I think this is a duplicate of #1109.

Nedilko commented 1 year ago

I created client a wrapper, where I simply use hook useServerInsertedHTML. Inside this hook I return style tag.

leonace924 commented 1 year ago

@Nedilko, could you put the code snippet here? I didn't find the solution Thank you