Skip to content

Chakra UI / Emotion integration #756

Closed Answered by lennerd
tmarnet asked this question in Q&A
Discussion options

You must be logged in to vote

I got it running (even without rendering the current route twice). The trick is to you some sort of placeholder inside the head of the rendered string. This placeholder gets then replaced with the actual styles from the emotion cache.

// app/entry.server.tsx
import { CacheProvider } from "@emotion/react";
import createEmotionServer from "@emotion/server/create-instance";
import { renderToString } from "react-dom/server";
import type { EntryContext } from "remix";
import { RemixServer } from "remix";
import createEmotionCache from "./utils/create-emotion-cache";
import StylesPlaceholderContext from "./utils/styles-placeholder-context";

export default function handleRequest(
  request: Req…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by machour
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants