Skip to content

Commit 4a560da

Browse files
committed
Apply changesets and update CHANGELOG
1 parent 3f38206 commit 4a560da

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,26 @@ export default function Layout({ children }) {
158158
}
159159
```
160160

161+
If you prefer SSR over SSG for your entire app, you can wrap entire app with `ServerTarget` as follows:
162+
163+
```tsx
164+
// app/layout.jsx
165+
import { Core } from "nextjs-darkmode"; // for better tree-shaking
166+
import { ServerTarget } from "nextjs-darkmode/server";
167+
168+
export default function Layout({ children }) {
169+
return (
170+
<ServerTarget tag="html" lang="en">
171+
<head />
172+
<body>
173+
<Core />
174+
{children}
175+
</body>
176+
</ServerTarget>
177+
);
178+
}
179+
```
180+
161181
### Switch
162182

163183
An elegant color switch to toggle color schemes:
@@ -332,6 +352,8 @@ Now you can use dark-mode specific classes:
332352
<h1 className="text-black dark:text-white">
333353
```
334354

355+
> When you use Tailwind, make sure you replace `html` in `app/layout` to `<ServerTarget tag="html"...` to avoid FOUC.
356+
335357
## Performance
336358

337359
`nextjs-darkmode` is designed to be fully tree-shakable, including only the code you use. For instance, if you only use the `useMode` hook, the rest of the library's code will be removed during the build process.

0 commit comments

Comments
 (0)