Skip to content

Commit b063d6b

Browse files
authored
chore: docs for next.js server events (#935)
* add server event tracking section * bump requirements * add requirements table, fix usage language * fix extra space
1 parent 5a49041 commit b063d6b

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

docs/sdk/client-side-sdks/nextjs/nextjs-usage-app.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,39 @@ export default MyComponent = function () {
155155

156156
#### Server Component
157157

158-
Currently, tracking events in server components is not supported due to limitations in Next.js.
159-
Please trigger any event tracking from client components.
158+
:::note
159+
Event tracking in server components requires Next.js SDK version >= 3.0.0 and Next.js >= 15.1.0.
160+
:::
161+
162+
```typescript tsx
163+
import * as React from 'react'
164+
import { MyComponent } from './components'
165+
import { track } from './devcycle'
166+
167+
export const MyServerComponent = async function () {
168+
await track({ type: 'myEvent' })
169+
return <MyComponent />
170+
}
171+
```
172+
173+
:::caution
174+
If you are not hosting your Next.js application on Vercel,
175+
you might see runtime errors if `waitUntil` is not supported by the platform and will be
176+
required to set `disableCustomEventLogging` and `disableAutomaticEventLogging` options to `true`:
177+
178+
```typescript
179+
export const { getVariableValue, getClientContext } = setupDevCycle({
180+
serverSDKKey: process.env.DEVCYCLE_SERVER_SDK_KEY ?? '',
181+
clientSDKKey: process.env.NEXT_PUBLIC_DEVCYCLE_CLIENT_SDK_KEY ?? '',
182+
userGetter: getUserIdentity,
183+
options: {
184+
disableAutomaticEventLogging: true,
185+
disableCustomEventLogging: true,
186+
},
187+
})
188+
```
189+
See [Next.js docs](https://nextjs.org/docs/app/api-reference/functions/after) and your provider's docs for more info.
190+
:::
160191
161192
### Getting all Variables
162193

docs/sdk/client-side-sdks/nextjs/nextjs.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ This SDK depends on the [fetch](https://github.com/BuilderIO/this-package-uses-f
2626
- support for static page rendering
2727
- exclude component code from client bundle when feature is disabled
2828

29-
## Limitations
30-
- Minimum Next.js version: 14.1
31-
- Minimum React version: 18.2
32-
- Variable evaluations and custom events are only tracked in client components in App Router.
29+
## Requirements
30+
31+
| SDK Version | Minimum Next.js Version | Minimum React Version |
32+
|-------------|-------------------------|----------------------|
33+
| 3.0.0+ | 15.1.0 | 18.2 |
34+
| 2.0.0+ | 14.1.0 | 18.2 |

0 commit comments

Comments
 (0)