Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation server side rendering #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Dec 8, 2021

  1. Improve documentation server side rendering

    Hi there, I just started using Stitches in a [new NextJS project](https://github.com/ontola/home), and I love it! Really nice stuff. The docs were clean and concise, the API is a blast to use and I really like that it supports SSR.
    
    However, when I tried to render my stuff on the server, I saw this annoying flash, presumably because the styles were only being created when the JS was parsed. I read the docs again, but didn't notice my issue. I used `dangerouslySetInnerHTML={{ __html: getCssText() }}`, but no luck. When I read the output of `getCssText()`, I saw only my theme variables - not my components. I knew I was close to a solution. Finally, I tried changing my `import from '@stitches/react'` to `import from '../stitches.config'`, and everything was fine. I felt stupid as I noticed that the docs do indeed mention that I should import this.
    
    However, I think this message can be conveyed more clearly. 
    
    The first problem is [here](https://stitches.dev/docs/installation#use-it), in the very first 'use it' block. It shows importing `styled` from `@stitches` instead of `stitches.config`. I suggest changing the order, and never importing from `stitches`.
    
    The second problem, perhaps more importantly, is that the [Server side rendering docs](https://stitches.dev/docs/server-side-rendering) don't mention this important thing.
    joepio authored Dec 8, 2021
    Configuration menu
    Copy the full SHA
    0f42b16 View commit details
    Browse the repository at this point in the history