feat: first draft of @hocuspocus/provider-react package#1059
Merged
feat: first draft of @hocuspocus/provider-react package#1059
Conversation
f558b20 to
66de275
Compare
14da897 to
3b8add4
Compare
3b8add4 to
0a664c4
Compare
bdbch
requested changes
Apr 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a first draft of a new @hocuspocus/provider-react package intended to provide React components/hooks for managing Hocuspocus provider lifecycle (especially around React StrictMode), and adds a playground route to demo it.
Changes:
- Adds
packages/provider-reactwith contexts, components (HocuspocusProviderWebsocketComponent,HocuspocusRoom), and hooks (connection/sync status, awareness, event subscription). - Updates the playground frontend to include a new
/react-provider/[slug]demo route and workspace wiring. - Replaces several
@ts-ignoreusages with@ts-expect-errorand makes small provider/internal adjustments.
Reviewed changes
Copilot reviewed 35 out of 37 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Expands root TS include to TSX and adjusts JSX setting. |
| tests/utils/flushRedis.ts | Replaces @ts-ignore with @ts-expect-error. |
| tests/extension-s3/fetch.ts | Replaces @ts-ignore with @ts-expect-error. |
| tests/extension-logger/onListen.ts | Replaces @ts-ignore with @ts-expect-error. |
| pnpm-lock.yaml | Adds lock entries for the new provider-react workspace usage and deps. |
| playground/frontend/package.json | Adds @hocuspocus/provider-react and yjs to deps. |
| playground/frontend/next.config.ts | Adds Next webpack alias for the new workspace package source. |
| playground/frontend/app/react-provider/layout.tsx | Adds nested layout for the new demo route. |
| playground/frontend/app/react-provider/[slug]/page.tsx | Adds page wiring for the new demo route. |
| playground/frontend/app/react-provider/[slug]/ConnectedUsers.tsx | Demo UI using useHocuspocusAwareness(). |
| playground/frontend/app/react-provider/[slug]/CollaborativeEditor.tsx | Demo editor using useHocuspocusProvider() and TipTap. |
| playground/frontend/app/react-provider/[slug]/CollaborationStatus.tsx | Demo status UI using provider-react hooks/events. |
| playground/frontend/app/react-provider/[slug]/ArticleEditor.tsx | Demo composition of websocket component + room + UI. |
| playground/frontend/app/layout.tsx | Adds navigation section for the new demo route. |
| playground/frontend/app/articles/[slug]/CollaborationStatus.tsx | UI tweak and adds unsynced threshold styling/banner. |
| playground/backend/src/webhook.ts | Replaces @ts-ignore with @ts-expect-error. |
| playground/backend/src/tiptapcollab.ts | Replaces @ts-ignore with @ts-expect-error. |
| playground/backend/src/load-document.ts | Replaces @ts-ignore with @ts-expect-error. |
| playground/backend/src/default.ts | Replaces @ts-ignore with @ts-expect-error (commented code). |
| packages/transformer/src/Tiptap.ts | Replaces @ts-ignore with @ts-expect-error. |
| packages/transformer/src/Prosemirror.ts | Replaces @ts-ignore with @ts-expect-error. |
| packages/provider/src/version.ts | Replaces @ts-ignore with @ts-expect-error. |
| packages/provider/src/MessageReceiver.ts | Adds case block braces and replaces @ts-ignore with @ts-expect-error. |
| packages/provider/src/HocuspocusProvider.ts | Normalizes type-only import and replaces @ts-ignore with @ts-expect-error. |
| packages/provider-react/tsconfig.json | Adds package-level TS config overriding JSX mode. |
| packages/provider-react/src/types.ts | Adds provider-react public types. |
| packages/provider-react/src/index.ts | Exports provider-react API surface. |
| packages/provider-react/src/hooks/* | Adds hooks for provider access, events, status, awareness. |
| packages/provider-react/src/context.ts | Adds contexts for websocket and room provider instances. |
| packages/provider-react/src/HocuspocusRoom.tsx | Adds room component that creates/attaches a provider. |
| packages/provider-react/src/HocuspocusProviderWebsocketComponent.tsx | Adds websocket component intended to share a websocket across rooms. |
| packages/provider-react/package.json | Adds new package metadata and peer deps. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8b989b9 to
17cc7fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The idea of this package is to remove all issues around rerendering during development in React. Strict mode triggers hooks twice, which is confusing (the network tab shows two websockets, one is dead and another is connected), and can cause timing issues (the server doesnt support opening the same document name twice over the same websocket connection), so if a disconnect and connect happen really fast, the state may mix and connections break.
Status: Needs careful testing.