diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-06-01 21:19:05 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-06-01 21:19:51 -0700 |
| commit | 0d35e75edbc75f186e4a1ed52fbc3549ee9f5cd6 (patch) | |
| tree | 90abc1a6d556fc54e4277907dc340736791a5677 /src/app/registry.tsx | |
init commit
Diffstat (limited to 'src/app/registry.tsx')
| -rw-r--r-- | src/app/registry.tsx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/app/registry.tsx b/src/app/registry.tsx new file mode 100644 index 0000000..4a5a4e1 --- /dev/null +++ b/src/app/registry.tsx @@ -0,0 +1,26 @@ +"use client"; +import React, { useState } from "react"; +import { useServerInsertedHTML } from "next/navigation"; +import { ServerStyleSheet, StyleSheetManager } from "styled-components"; + +export default function StyledComponentsRegistry({ + children, +}: { + children: React.ReactNode; +}) { + const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet()); + + useServerInsertedHTML(() => { + const styles = styledComponentsStyleSheet.getStyleElement(); + styledComponentsStyleSheet.instance.clearTag(); + return <>{styles}</>; + }); + + if (typeof window !== "undefined") return <>{children}</>; + + return ( + <StyleSheetManager sheet={styledComponentsStyleSheet.instance}> + {children as React.ReactElement} + </StyleSheetManager> + ); +} |
