docs: clarify options prop requirement for Pages Router SSR with serverState
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- next.js, typescript
- Domain
- documentation
Research direction
Start with the Pages Router SSR documentation at the linked URL, then read react.tsx lines 8-13 and 35-54 to confirm the FlagsmithProvider initialization contract. Update the example and explanatory note to cover serverState, the options prop, preventFetch, and the manual-init consequence; completion is defined by the listed acceptance criteria.
Written by the indexing model from the issue text.
Description
Description
Problem
The current Next.js Pages Router SSR documentation example shows how to use serverState but doesn't mention that the options prop is required for automatic client-side initialization.
This leads to a common issue where developers following the docs experience:
useFlagsmithLoading()stuck on{ isLoading: true, isFetching: true }- Loading states never updating
- Confusion about why hooks don't work as expected
Root Cause
The FlagsmithProvider component has an intentional design contract:
// From react.tsx type definition
options?: Parameters<IFlagsmith['init']>[0] // Initialisation options, if you do not provide this you will have to call init manually
- Without
options: Users must callflagsmith.init()manually - With
options: Component automatically callsinit()on mount
This design is intentional but not documented in the Pages Router example.
Current Documentation Gap
The current example shows:
<FlagsmithProvider
flagsmith={flagsmithRef.current}
serverState={flagsmithState}
>
<Component {...pageProps} />
</FlagsmithProvider>
Issue: This works for rendering flags, but hooks like useFlagsmithLoading() will be stuck because init() was never called to register callbacks.
What Needs to Be Documented
The documentation should clearly explain:
- The
optionsprop is required for automatic client-side initialization - When using
serverState, you should passoptions={{ preventFetch: true }} - Why
preventFetch: trueis recommended (avoids duplicate API calls, uses server-side flags) - What happens without
options(hooks won't work, manualinit()required)
Suggested Fix
Update the Pages Router documentation example to:
- Include
options={{ preventFetch: true }}in the code example - Add a callout/note explaining why it's needed for hooks to work
- Explain the consequence of omitting it (stuck loading states)
Note: The code already has a comment in the type definition (react.tsx:10), but the documentation doesn't reflect this requirement.
Additional Context
User Impact
This affects developers:
- Following the Pages Router SSR documentation
- Using
useFlagsmithLoading()or other hooks - New to Flagsmith (not familiar with the initialization contract)
Customer Report
A customer recently reported this exact issue:
- Using Next.js 15 Pages Router
- Following the docs exactly as written
useFlagsmithLoading()stuck on loading state- Adding
options={{ preventFetch: true }}immediately fixed it
Reproduction
I've created a minimal reproduction project that demonstrates:
- The issue when
optionsis omitted - The fix when
options={{ preventFetch: true }}is added
Acceptance Criteria
- Pages Router example updated to include
options={{ preventFetch: true }} - Clear note/callout added explaining why
optionsis required - Documentation explains what happens without the
optionsprop
Related Code
- Component type definition:
react.tsx:8-13 - Initialization logic:
react.tsx:35-54
- Dominant language
- TypeScript
- Stars
- 67
- Forks
- 47
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith-js-client
-
`init({ traits })` double-wraps `{ value, transient }` trait objects, sending a nested `trait_value`Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Flagsmith/flagsmith-js-client#444 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Flagsmith/flagsmith-js-client#445 ·
-
Dependency DashboardOpen
Difficulty 1/5 Under an hour Newbie friendliness 20/100
Flagsmith/flagsmith-js-client#435 ·
-
Move module-scope Emitter in react.tsx into the ProviderPossibly taken @EngineerOnTravel claimed this 101 days ago. Openbug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Flagsmith/flagsmith-js-client#391 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Flagsmith/flagsmith-js-client#330 ·
All issues in Flagsmith/flagsmith-js-client
Similar issues
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
mermaid-js/mermaid-v13#1370 ·
Maintainers usually reply within 1 day
-
compiler: the island_chunks_not_emitted report gives a count but not which islands were skippedOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Broken Website
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
darkreader/darkreader#16259 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ARTPARK-SAHAI-ORG/calibrate-frontend#919 ·
Maintainers usually reply within 1 day