You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example demonstrates how to integrate the Unleash Toolbar with a Next.js App Router application using **built-in React hooks**.
3
+
This example demonstrates how to integrate the Unleash Toolbar with a Next.js App Router application for both **client-side and server-side rendering**.
4
4
5
5
## Features
6
6
7
7
- Next.js 15 with App Router
8
8
- TypeScript
9
9
- Tailwind CSS
10
-
- Unleash SDK integration with client-side feature flags
No event subscriptions. No state management. Just hooks that work.
102
+
Visit `/server-demo` to see server component documentation.
103
+
104
+
## How It Works
105
+
106
+
1.**Client-side**: Toolbar wraps the Unleash client and stores overrides in localStorage + cookies
107
+
2.**Server-side**: `applyToolbarOverrides()` reads from cookies and modifies flag definitions before evaluation
108
+
3.**Sync**: Client changes sync to cookies automatically, server picks them up on next request
109
+
4.**FOUC**: Accept Flash of Unstyled Content (server renders original, client updates) - fine for dev tooling
59
110
60
111
## Using the Toolbar
61
112
62
113
1. The toolbar appears at the bottom of the page
63
114
2. Click the "Flags" tab to override feature flags
64
115
3. Click the "Context" tab to override context fields
65
-
4. Changes trigger automatic re-renders
66
-
5.Overrides are persisted in localStorage
67
-
6.Refresh the page to see that overrides persist
116
+
4. Changes trigger automatic re-renders in client components
117
+
5.Server components receive overrides on next page load
118
+
6.Overrides persist across page reloads via localStorage + cookies
68
119
69
120
## Feature Flags in Demo
70
121
@@ -76,4 +127,4 @@ No event subscriptions. No state management. Just hooks that work.
76
127
77
128
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
78
129
79
-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
130
+
**Note**: Disable the toolbar in production by setting `toolbarOptions={undefined}` or using environment checks.
0 commit comments