Skip to content

Commit bed27ce

Browse files
author
Saiya
committed
feat: update readme
1 parent c4925ae commit bed27ce

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<a href="https://www.typescriptlang.org/" target="_blank">
2020
<img src="https://img.shields.io/badge/TypeScript-5.0%2B-blue?logo=typescript&style=flat-square" alt="TypeScript" />
2121
</a>
22+
<a href="#ssr-ssg-support" target="_blank">
23+
<img src="https://img.shields.io/badge/SSR%2FSSG-Compatible-brightgreen?style=flat-square" alt="SSR/SSG Compatible" />
24+
</a>
2225
</p>
2326

2427
A lightweight, flexible React sticky container and item component library. Easily create sticky headers, sections, and advanced sticky layouts with support for multiple modes and edge cases.
@@ -28,6 +31,7 @@ A lightweight, flexible React sticky container and item component library. Easil
2831
- 📦 Simple API: `<StickyContainer>` and `<StickyItem>`
2932
- 🧩 Supports `replace`, `stack`, and `none` sticky modes
3033
- 🏷️ Customizable offset, z-index (baseZIndex), and sticky logic
34+
- 🔄 Supports SSR/SSG (Next.js, Gatsby, Astro, etc.)
3135
- 🧪 Handles edge cases: empty sections, dynamic heights, zero-height headers, long headers, etc.
3236
- ⚡️ Written in TypeScript, fully typed
3337
- 🧪 Includes demo pages for real-world scenarios
@@ -104,6 +108,52 @@ Open [http://localhost:5173](http://localhost:5173) and switch between demo page
104108
* [Mixed mode](http://localhost:5173/#mixed-mode) mix replace/stack/none mode
105109
* [Nested](http://localhost:5173/#dynamic-height) nest sticky containers
106110
* [Dynamic sticky items](http://localhost:5173/#nested) dynamic sticky items(add/remove)
111+
* [Dynamic offsetTop](http://localhost:5173/#dynamic-offset) dynamic offsetTop that adapts to header height changes
112+
113+
## SSR/SSG Support
114+
115+
React Sticky Kit supports Server-Side Rendering (SSR) and Static Site Generation (SSG), working seamlessly with frameworks like Next.js, Gatsby, Astro, and more.
116+
117+
### Next.js Example
118+
119+
```tsx
120+
// pages/index.tsx
121+
import { StickyContainer, StickyItem } from 'react-sticky-kit'
122+
import 'react-sticky-kit/dist/style.css'
123+
124+
export default function Home() {
125+
return (
126+
<StickyContainer>
127+
<StickyItem>
128+
<header>Sticky Header</header>
129+
</StickyItem>
130+
<main>Content...</main>
131+
</StickyContainer>
132+
)
133+
}
134+
```
135+
136+
### Astro Example
137+
138+
```astro
139+
---
140+
// src/pages/index.astro
141+
import { StickyContainer, StickyItem } from 'react-sticky-kit'
142+
import 'react-sticky-kit/dist/style.css'
143+
---
144+
145+
<html>
146+
<head>...</head>
147+
<body>
148+
<StickyContainer client:load>
149+
<StickyItem>
150+
<header>Sticky Header</header>
151+
</StickyItem>
152+
<div>Content...</div>
153+
</StickyContainer>
154+
</body>
155+
</html>
156+
```
107157

108158
## License
109159

0 commit comments

Comments
 (0)