Hahn-Solo Product Management
  • Dashboard
  • Technologies
  • Competitors
  • Tasks
Theme
Basic Information
Status
Open
Priority
Now
Category
Bug Fix
Repo
Content SDK PM
Effort
Moderate
Task ID
T-30885788
Details
Fix useSitecore in Server Components
Resolve issue #361 where `useSitecore` hook throws an error when invoked within a Server Component via `withDatasourceCheck`. The fix should either make the HOC server-component-safe or provide clear documentation that it requires a client boundary.
Why
The `useSitecore` hook is the v2.0 replacement for removed HOCs. If it fails in Server Components (the primary rendering mode), it blocks adoption of the new API surface.
Evidence
GitHub issue #361 (opened 2026-02-04, label: bug)
Details
Context: Issue #361 reports that the `useSitecore` hook -- the v2.0 replacement for removed HOCs like `useLoadImportMap` and `useComponentMap` -- throws an error when invoked within a Server Component via `withDatasourceCheck`. React hooks cannot run in Server Components. If `withDatasourceCheck` wraps a Server Component and calls `useSitecore` internally, it must be refactored to either use a server-safe data access pattern or require a client boundary.

Steps:
1. Examine `withDatasourceCheck` implementation -- determine whether it calls `useSitecore` internally
2. If so, refactor to provide a server-safe alternative (e.g., read from `SitecoreContext` via a server-compatible mechanism or split into `withDatasourceCheck` for client and `getDatasourceCheck` for server)
3. Update documentation to clarify which APIs are client-only vs server-safe
4. Add test coverage for Server Component usage

Acceptance criteria:
`withDatasourceCheck` works correctly in both Server and Client Components
Documentation clearly marks which APIs require `"use client"`
No regression in existing Client Component usage

Risks: This may require API surface changes that affect existing v2.0 adopters. If a breaking change is needed, ship it in v2.1.0 with clear migration notes. Consider deprecating the HOC pattern entirely in favor of a server-safe utility function.
Source Report
reports/product-management/content-sdk/2026-04-05-content-sdk-pm.md
Report date: Apr 5, 2026