CSS-in-JS Support #65
natemoo-re
started this conversation in
Ideas
Replies: 2 comments 6 replies
-
Maybe consider a zero-runtime library like Linaria, which does all its work at build time with Babel and a bundler (Rollup is supported)? |
Beta Was this translation helpful? Give feedback.
6 replies
-
I think I landed on the following option for v1.1.0. You can define a custom Document component at import { defineDocument, Html, Head, Main, MicrositeScript } from "microsite/document";
const Document = () => (
<Html>
<Head />
<body>
<Main />
<MicrositeScript />
</body>
</Html>
);
export default defineDocument(Document, {
async prepare({ renderPage }) {
const page = await renderPage();
const styles = await somePostRenderHook();
return { ...page, styles };
},
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As mentioned in the docs, CSS-in-JS is unsupported at the moment. This is because I'm not exposing the internal Document component wrapper (yet).
Next.js solution is to allow users to create a custom
_app.js
or_document.js
component, and this is where most CSS-in-JS libraries hook in to generate their stylesheets.I'd love community feedback on this, to see if there's a nicer API that could be exposed here. I'm very open to alternative suggestions.
Beta Was this translation helpful? Give feedback.
All reactions