-
-
Notifications
You must be signed in to change notification settings - Fork 128
feat(react-swr): React SWR Integration #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds an experimental @orpc/experimental-react-swr package (types, utils, runtime, tests), updates docs and READMEs to list SWR and adds a React SWR docs page and sidebar entry, extends shared types, and wires React-SWR tests into the Vitest workspace. Changes
Sequence Diagram(s)sequenceDiagram
participant C as React Component
participant SWR as useSWR Hook
participant U as createSWRUtils()
participant P as Procedure Utils
participant CL as oRPC Client
C->>U: orpc = createSWRUtils(client)
C->>SWR: useSWR(orpc.foo.key(), orpc.foo.fetcher())
SWR->>P: call fetcher (context includes SWR_OPERATION_CONTEXT_SYMBOL: fetcher)
P->>CL: client(input, { context, signal? })
CL-->>P: returns output or AsyncIterator
P-->>SWR: resolved data / events
SWR-->>C: data updates
sequenceDiagram
participant C as React Component
participant S as useSWRSubscription
participant P as Procedure Utils
participant CL as oRPC Client (stream)
participant It as AsyncIterator
C->>P: orpc.foo.subscriber(...) -> subscriber
C->>S: useSWRSubscription(key, subscriber)
S->>CL: client(input, { context: { type: 'subscriber'|'liveSubscriber' }, signal })
CL-->>It: returns AsyncIterator
loop stream
It-->>S: next() -> event
S-->>C: update data (append/reset or live)
end
C-->>S: unsubscribe (abort)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new integration for React SWR with oRPC, enabling developers to leverage SWR's powerful data fetching, caching, and revalidation capabilities with their oRPC clients. It includes a new dedicated package and comprehensive documentation covering various SWR patterns like data fetching, infinite queries, subscriptions, and mutations. The integration also provides utilities for cache invalidation and introduces an operation context for fine-grained control over request behavior.
Highlights
- New React SWR Integration Package: A new package,
@orpc/experimental-react-swr, has been introduced to provide a seamless integration layer between oRPC and React SWR. This package includes utilities for generating SWR keys, fetchers, subscribers, and mutators directly from oRPC client definitions. - Extensive Documentation for SWR Integration: Comprehensive documentation has been added under
docs/integrations/react-swr.md. This new page guides users through installation, setup, and various SWR patterns including data fetching (useSWR), infinite queries (useSWRInfinite), real-time subscriptions (useSWRSubscriptionwith.subscriberand.liveSubscriber), and data mutations (useSWRMutation). - Enhanced Cache Invalidation Capabilities: The integration provides dedicated utilities for managing SWR cache invalidation. The
.matcherfunction allows for granular control over which cached data should be revalidated, supporting both partial and exact matching strategies. - Automatic Operation Context for SWR Hooks: The new SWR integration introduces an
SWROperationContextthat is automatically added to the client context when SWR hooks invoke oRPC procedures. This context can be leveraged to configure request behaviors, such as dynamically setting HTTP methods based on the SWR operation type (e.g.,fetcher,mutator).
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new package @orpc/experimental-react-swr for integrating oRPC with React SWR. The changes include the core logic for the integration, comprehensive unit and end-to-end tests, and detailed documentation. The implementation is well-structured, using proxies to provide a great developer experience. The code is of high quality and well-tested. I have a couple of minor suggestions to improve the documentation and ensure consistency.
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
♻️ Duplicate comments (3)
packages/react-swr/README.md (2)
11-13: Update npm badge to the experimental package nameThe badge points to
@orpc/react-swrbut the package is@orpc/experimental-react-swr.Apply:
- <a href="https://www.npmjs.com/package/@orpc/react-swr"> - <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Freact-swr?logo=npm" /> + <a href="https://www.npmjs.com/package/@orpc/experimental-react-swr"> + <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fexperimental-react-swr?logo=npm" /> </a>
63-63: Header should reflect experimental package nameAlign the section header with the actual package name.
Apply:
-## `@orpc/react-swr` +## `@orpc/experimental-react-swr`apps/content/docs/integrations/react-swr.md (1)
182-201: Add missing RPCLink import in Operation Context exampleThis snippet uses RPCLink but doesn’t import it, which can trip up copy/paste users. Add the import:
+import { RPCLink } from '@orpc/client' import { SWR_OPERATION_CONTEXT_SYMBOL, SWROperationContext, } from '@orpc/experimental-react-swr'
🧹 Nitpick comments (33)
packages/shared/src/types.ts (1)
18-18: Add a brief doc comment for discoverabilityA short TSDoc helps future users find and understand this alias.
Apply:
+/** Extracts the yielded element type from an AsyncIterable. + * Example: AsyncIterable<number> -> number + */ export type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : neverpackages/react-swr/README.md (3)
41-42: Wording: use “Extensibility” (standard term) instead of “Extendability”Minor copy improvement.
Apply:
- - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors. + - **🔌 Extensibility**: Easily extend functionality with plugins, middleware, and interceptors.
71-71: Add alt text to the sponsors image (markdownlint MD045)Improves accessibility and satisfies MD lint.
Apply:
- <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/> + <img alt="Sponsors of unnoq" src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
50-51: Minor grammar and style tweaks in package descriptionsPolish for clarity and consistency.
Apply:
-- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract. -- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety. +- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement your API contract. +- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type safety.packages/react-swr/package.json (2)
28-35: Enable tree-shaking by marking the package as side-effect freeThis helps bundlers drop unused code and reduces bundle size.
"files": [ "dist" ], + "sideEffects": false, "scripts": { "build": "unbuild", "build:watch": "pnpm run build --watch", "type:check": "tsc -b" },
12-15: Improve discoverability with relevant keywordsAdding tech-specific keywords helps users find the package.
"keywords": [ "unnoq", - "orpc" + "orpc", + "react", + "swr", + "hooks", + "data-fetching" ],packages/react-swr/src/index.test.ts (1)
1-3: Make the assertion stronger by checking function identity and typeAssert it’s a function and that it’s the same symbol as
createRouterUtils(since it’s an alias). This guards against regressions where the alias might diverge.-it('exports createSWRUtils', async () => { - expect(Object.keys(await import('./index'))).toContain('createSWRUtils') -}) +it('exports createSWRUtils (alias of createRouterUtils)', async () => { + const mod = await import('./index') + expect(mod).toHaveProperty('createSWRUtils') + expect(typeof mod.createSWRUtils).toBe('function') + expect(mod.createSWRUtils).toBe(mod.createRouterUtils) +})packages/react-swr/tests/shared.tsx (1)
1-1: Nit: .tsx extension is unnecessaryThere’s no JSX in this file. Consider renaming to .ts for clarity and slightly faster TS transforms.
packages/react-swr/src/general-utils.test.ts (1)
16-20: Add assertion: exact should reject extra input keysStrengthen the exact-strategy test by asserting it rejects extra nested input properties. This guards against regressions where exactness could be relaxed.
Apply this diff:
it('strategy=exact', () => { expect(utils.matcher({ strategy: 'exact', input: { value1: 'test' } })([['test', 'path'], { input: { value1: 'test' } }])).toBe(true) expect(utils.matcher({ strategy: 'exact' })([['test', 'path'], { input: { value1: 'test' } }])).toBe(false) + // Extra input keys should fail for exact strategy + expect( + utils.matcher({ strategy: 'exact', input: { value1: 'test' } })( + [['test', 'path'], { input: { value1: 'test', value2: 'extra' } }] + ) + ).toBe(false) expect(utils.matcher({ strategy: 'exact', input: { value1: 'test' } })([['invalid'], { input: { value1: 'test' } }])).toBe(false) })packages/react-swr/src/utils.ts (1)
3-13: Use Object.is for equality and document undefined-as-wildcard semantics
- Object.is handles NaN and -0 precisely; it’s a better equality base case for structural subset checks.
- Document that undefined in the subset acts as a wildcard, which is intentional for key matching and avoids confusion.
Apply this diff:
-export function isSubsetOf(subsetKey: unknown, fullKey: unknown): boolean { - return subsetKey === fullKey +/** + * Determines if `subsetKey` is a structural subset of `fullKey`. + * + * Semantics: + * - Primitives: compared via Object.is (so NaN equals NaN; -0 differs from 0). + * - Objects: every own enumerable key in `subsetKey` must either be `undefined` (wildcard) + * or be a subset of the corresponding value in `fullKey`. + * - Arrays: every element of `subsetKey` must be a subset of the element at the same index in `fullKey`. + * - Special objects (Date, Map, Set, etc.) are not treated as plain objects/arrays and only match via Object.is. + */ +export function isSubsetOf(subsetKey: unknown, fullKey: unknown): boolean { + return Object.is(subsetKey, fullKey) ? true : typeof subsetKey !== typeof fullKey ? false : isObject(subsetKey) && isObject(fullKey) ? Object.keys(subsetKey).every(key => subsetKey[key] === undefined || isSubsetOf(subsetKey[key], fullKey[key])) : Array.isArray(subsetKey) && Array.isArray(fullKey) ? subsetKey.every((value, index) => isSubsetOf(value, fullKey[index])) : false }packages/react-swr/src/utils.test.ts (2)
3-43: Good breadth of cases; consider one more array non-subsetCoverage is strong, including nested structures and special-object mismatch. Add a length-mismatch negative case for arrays.
34-37: Add array length-mismatch negative caseExplicitly assert a longer subset array is not a subset of a shorter full array.
Apply this diff:
// Non-subset arrays expect(isSubsetOf([1, 2], [2, 3])).toBe(false) expect(isSubsetOf([[1]], [[2]])).toBe(false) + expect(isSubsetOf([1, 2, 3], [1, 2])).toBe(false)Additionally, if you adopt Object.is in utils.ts, consider adding:
// Identical values (Object.is semantics) expect(isSubsetOf(NaN, NaN)).toBe(true)packages/react-swr/src/general-utils.test-d.ts (1)
19-28: Exact strategy tests look correct; consider one more negative case.You already assert missing nested fields and missing input are errors on the required variant. Optionally add a negative case for the optional variant with malformed nested input (e.g., wrong type) to further pin the exact strategy’s behavior.
packages/react-swr/src/index.ts (1)
5-6: Be deliberate about exporting internal utilities.Exporting everything from './utils' (e.g., isSubsetOf) makes those helpers part of your public API and subject to semver. If they’re internal, consider not exporting or exporting under an explicit “internal” namespace.
-export * from './utils' +// Consider limiting what's public, or omitting if internal-only: +// export { somePublicUtility } from './utils'packages/react-swr/src/router-utils.test.ts (2)
1-7: Spying imported functions can be fragile with ESM; prefer vi.mock for reliable interception.Because router-utils imports createGeneralUtils/createProcedureUtils as named bindings, vi.spyOn on the module namespace object may not intercept internal calls in all ESM setups. Consider hoisted vi.mock with partial passthrough to guarantee call interception.
Here’s a resilient pattern:
-import * as generalUtilsModule from './general-utils' -import * as procedureUtilsModule from './procedure-utils' -import { createRouterUtils } from './router-utils' - -const procedureUtilsSpy = vi.spyOn(procedureUtilsModule, 'createProcedureUtils') -const generalUtilsSpy = vi.spyOn(generalUtilsModule, 'createGeneralUtils') +vi.mock('./general-utils', async () => { + const actual = await vi.importActual<typeof import('./general-utils')>('./general-utils') + return { + ...actual, + createGeneralUtils: vi.fn(actual.createGeneralUtils), + } +}) +vi.mock('./procedure-utils', async () => { + const actual = await vi.importActual<typeof import('./procedure-utils')>('./procedure-utils') + return { + ...actual, + createProcedureUtils: vi.fn(actual.createProcedureUtils), + } +}) +import * as generalUtilsModule from './general-utils' +import * as procedureUtilsModule from './procedure-utils' +import { createRouterUtils } from './router-utils' + +const generalUtilsSpy = generalUtilsModule.createGeneralUtils as unknown as vi.Mock +const procedureUtilsSpy = procedureUtilsModule.createProcedureUtils as unknown as vi.MockThis ensures router-utils uses the mocked creators the tests assert against.
62-65: Strengthen the symbol case by asserting no factory invocations.Verifying that symbol access doesn’t recurse is good. Also assert the creators were not called due to symbol access for extra safety.
it('not recursive on symbol', async () => { const utils = createRouterUtils(client) as any expect(utils[Symbol.for('a')]).toBe(undefined) + expect(generalUtilsSpy).not.toHaveBeenCalled() + expect(procedureUtilsSpy).not.toHaveBeenCalled() })packages/react-swr/tests/e2e.test-d.tsx (5)
16-21: Align fetcher with the key’s path to avoid mismatches.Using a key from orpc.nested.ping with a fetcher from orpc.ping may confuse readers and can lead to runtime mismatches. Prefer keeping them aligned.
const swr = useSWR( orpc.nested.ping.key({ input: { input: 123 } }), - orpc.ping.fetcher(), + orpc.nested.ping.fetcher(), )
24-29: Track the “invalid key” FIXME or add a ts-expect-error when types are ready.Once the key typing is enforced, add a ts-expect-error on the call line to lock the contract. I can help wire the Key type into the SWR hook overloads when you’re ready.
63-67: Place @ts-expect-error on the call line so the compiler reliably associates it.Currently the directive sits above the second argument; it may not catch the error on the call. Move it to the call line.
-useSWRSubscription( - 'invalid', - // @ts-expect-error: invalid key - streamedOrpc.streamed.subscriber({ maxChunks: 2 }), -) +// @ts-expect-error: invalid key +useSWRSubscription( + 'invalid', + streamedOrpc.streamed.subscriber({ maxChunks: 2 }), +)
78-82: Same here: move @ts-expect-error to the call line.-useSWRSubscription( - 'invalid', - // @ts-expect-error: invalid key - streamedOrpc.streamed.liveSubscriber(), -) +// @ts-expect-error: invalid key +useSWRSubscription( + 'invalid', + streamedOrpc.streamed.liveSubscriber(), +)
41-53: Type previousPageData in useSWRInfinite (when feasible).Once key typing is threaded through the infinite key loader, assert previousPageData’s type to close the FIXME.
I can propose the necessary generic threading in the createFetcher/mutator types to infer page data in the key loader, if you want to pursue this in this PR.
packages/react-swr/tests/e2e.test.tsx (2)
102-117: Optional: Also isolate cache per render using SWRConfig wrapperIn addition to clearing the global cache, wrapping each renderHook with a fresh SWR provider prevents future flakiness and test coupling:
- Outside selected lines (example usage):
import { SWRConfig } from 'swr' const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => ( <SWRConfig value={{ provider: () => new Map() }}>{children}</SWRConfig> ) renderHook(() => { /* ... */ }, { wrapper })If you prefer this approach, I can send a small refactor to add the wrapper to each renderHook call.
15-26: Nit: Use matching fetcher for readabilityFunctionally fine because your fetcher ignores the path segment of the SWR key, but for clarity and to reduce future confusion, consider using the fetcher from the same path used to build the key:
- const fetcher = vi.fn(orpc.ping.fetcher()) + const fetcher = vi.fn(orpc.nested.ping.fetcher())apps/content/docs/integrations/react-swr.md (1)
171-175: Grammar: add “the” for clarity“It’s an alias for corresponding procedure client.” → “It’s an alias for the corresponding procedure client.”
-Use `.call` to call a procedure client directly. It's an alias for corresponding procedure client. +Use `.call` to call a procedure client directly. It's an alias for the corresponding procedure client.packages/react-swr/src/procedure-utils.test.ts (4)
30-31: Don’t use async describe callbacksIn Vitest/Jest, describe callbacks shouldn’t be async. Make them sync (tests remain async individually):
-describe('.subscriber', async () => { +describe('.subscriber', () => {
153-154: Don’t use async describe callbacksSame here; make it sync:
-describe('.liveSubscriber', async () => { +describe('.liveSubscriber', () => {
163-166: Remove unnecessary await when creating unsubscribesubscriber/liveSubscriber return an unsubscribe function synchronously. Awaiting the call is unnecessary:
-const unsubscribe = await subscriber([['ping'], { input: { search: '__search__' } }], { next }) +const unsubscribe = subscriber([['ping'], { input: { search: '__search__' } }], { next })
33-57: Optional: Reduce flakiness by using fake timersUsing real setTimeouts (10–100ms) in generator mocks can be flaky in CI. Consider switching to vi.useFakeTimers() and advancing timers to make these tests deterministic. I can send a refactor if you’d like.
Also applies to: 59-84, 86-104, 105-124, 125-138, 139-151, 155-176, 178-196, 197-216, 217-230, 231-241
packages/react-swr/src/router-utils.ts (2)
32-38: Prevent “thenable” detection by frameworksReturning a value for the 'then' property can cause the proxy to be treated as a Promise by some frameworks/tools. Explicitly return undefined for 'then':
}, { get(target, prop) { const value = Reflect.get(target, prop) if (typeof prop !== 'string') { return value } + // Avoid being treated as a thenable (e.g., by await or framework introspection) + if (prop === 'then') { + return undefined + }
25-31: Optional: Only attach procedure utils on leavesAt runtime, the root (non-leaf) proxy currently exposes procedure utils like .call, which can be confusing and error-prone (since calling root.call would try to invoke a non-function client). Consider only merging procedure utils when client is a function:
- const procedureUtils = createProcedureUtils(client as any, { path }) + const procedureUtils = typeof (client as any) === 'function' + ? createProcedureUtils(client as any, { path }) + : {}This reduces accidental misuse without affecting typed access.
packages/react-swr/src/procedure-utils.ts (2)
68-68: Nit: readability of tuple destructuring.Add a space after the comma in the tuple destructuring for consistency/readability.
Apply this diff:
- return ([,{ input }], { next }) => { + return ([, { input }], { next }) => {- return ([,{ input }], { next }) => { + return ([, { input }], { next }) => {Also applies to: 120-120
41-45: Optional: factor out operation context attachment to avoid repetition.The operation-tagging object shape is repeated in four places. A small helper reduces duplication and prevents future inconsistencies.
You can add this helper (outside the selected range):
function withSWROperationContext<T extends Record<string | number | symbol, unknown>>( ctx: T, type: SWROperationContext[typeof SWR_OPERATION_CONTEXT_SYMBOL]['type'], ): T & SWROperationContext { return { ...ctx, [SWR_OPERATION_CONTEXT_SYMBOL]: { type }, } as T & SWROperationContext }And then use:
- context: { ...context, [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'fetcher' } } satisfies SWROperationContext + context: withSWROperationContext(context, 'fetcher')packages/react-swr/src/types.ts (1)
33-33: Prefer a readonly tuple for keys.SWR keys are treated as identifiers; using a readonly tuple prevents accidental mutation and aligns with SWR’s expectation of immutable keys.
Apply this diff:
-export type Key<TInput> = [path: readonly string[], options: KeyMeta<TInput>] +export type Key<TInput> = readonly [path: readonly string[], options: KeyMeta<TInput>]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (27)
apps/content/.vitepress/config.ts(1 hunks)apps/content/docs/integrations/react-swr.md(1 hunks)apps/content/package.json(1 hunks)packages/react-swr/.gitignore(1 hunks)packages/react-swr/README.md(1 hunks)packages/react-swr/package.json(1 hunks)packages/react-swr/src/general-utils.test-d.ts(1 hunks)packages/react-swr/src/general-utils.test.ts(1 hunks)packages/react-swr/src/general-utils.ts(1 hunks)packages/react-swr/src/index.test.ts(1 hunks)packages/react-swr/src/index.ts(1 hunks)packages/react-swr/src/procedure-utils.test-d.ts(1 hunks)packages/react-swr/src/procedure-utils.test.ts(1 hunks)packages/react-swr/src/procedure-utils.ts(1 hunks)packages/react-swr/src/router-utils.test-d.ts(1 hunks)packages/react-swr/src/router-utils.test.ts(1 hunks)packages/react-swr/src/router-utils.ts(1 hunks)packages/react-swr/src/types.ts(1 hunks)packages/react-swr/src/utils.test.ts(1 hunks)packages/react-swr/src/utils.ts(1 hunks)packages/react-swr/tests/e2e.test-d.tsx(1 hunks)packages/react-swr/tests/e2e.test.tsx(1 hunks)packages/react-swr/tests/shared.tsx(1 hunks)packages/react-swr/tsconfig.json(1 hunks)packages/shared/src/types.test-d.ts(2 hunks)packages/shared/src/types.ts(1 hunks)vitest.workspace.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (13)
packages/react-swr/src/router-utils.test.ts (1)
packages/react-swr/src/router-utils.ts (1)
createRouterUtils(19-54)
packages/react-swr/src/general-utils.ts (4)
packages/react-swr/src/types.ts (4)
MatcherStrategy(35-35)CreateMatcherOptions(37-46)Matcher(48-48)Key(33-33)packages/shared/src/args.ts (2)
MaybeOptionalOptions(1-3)resolveMaybeOptionalOptions(5-7)packages/react-swr/src/procedure-utils.ts (1)
key(48-52)packages/react-swr/src/utils.ts (1)
isSubsetOf(3-13)
packages/react-swr/src/general-utils.test.ts (1)
packages/react-swr/src/general-utils.ts (1)
createGeneralUtils(12-32)
packages/shared/src/types.test-d.ts (1)
packages/shared/src/types.ts (1)
InferAsyncIterableYield(18-18)
packages/react-swr/src/procedure-utils.test-d.ts (4)
packages/contract/src/error.ts (1)
ErrorFromErrorMap(49-49)packages/contract/tests/shared.ts (1)
baseErrorMap(12-17)packages/react-swr/src/procedure-utils.ts (1)
ProcedureUtils(11-39)packages/client/src/types.ts (1)
Client(26-28)
packages/react-swr/src/utils.test.ts (1)
packages/react-swr/src/utils.ts (1)
isSubsetOf(3-13)
packages/react-swr/src/utils.ts (1)
packages/shared/src/object.ts (1)
isObject(31-39)
packages/react-swr/src/router-utils.test-d.ts (6)
packages/react-swr/src/router-utils.ts (1)
RouterUtils(8-13)packages/server/src/router-client.ts (1)
RouterClient(15-20)packages/react-swr/src/general-utils.ts (1)
GeneralUtils(6-10)packages/react-swr/src/procedure-utils.ts (1)
ProcedureUtils(11-39)packages/contract/src/error.ts (1)
ErrorFromErrorMap(49-49)packages/contract/tests/shared.ts (1)
baseErrorMap(12-17)
packages/react-swr/src/router-utils.ts (5)
packages/client/src/types.ts (2)
NestedClient(30-32)Client(26-28)packages/react-swr/src/procedure-utils.ts (2)
ProcedureUtils(11-39)createProcedureUtils(41-168)packages/react-swr/src/general-utils.ts (2)
GeneralUtils(6-10)createGeneralUtils(12-32)packages/react-swr/src/index.ts (1)
createRouterUtils(4-4)packages/shared/src/array.ts (1)
toArray(1-3)
packages/react-swr/tests/e2e.test.tsx (1)
packages/react-swr/src/procedure-utils.ts (1)
fetcher(54-63)
packages/react-swr/src/types.ts (2)
packages/shared/src/index.ts (1)
PartialDeep(23-23)packages/react-swr/src/procedure-utils.ts (1)
key(48-52)
packages/react-swr/src/procedure-utils.test.ts (2)
packages/react-swr/src/procedure-utils.ts (4)
createProcedureUtils(41-168)fetcher(54-63)subscriber(65-115)mutator(157-166)packages/react-swr/src/types.ts (1)
SWR_OPERATION_CONTEXT_SYMBOL(5-5)
packages/react-swr/src/procedure-utils.ts (5)
packages/client/src/types.ts (1)
Client(26-28)packages/shared/src/args.ts (2)
MaybeOptionalOptions(1-3)resolveMaybeOptionalOptions(5-7)packages/react-swr/src/types.ts (11)
CreateKeyOptions(13-14)Key(33-33)CreateFetcherOptions(50-51)Fetcher(66-66)CreateSubscriberOptions(70-85)Subscriber(87-90)Mutator(68-68)resolveCreateKeyOptions(16-27)resolveCreateFetcherOptions(53-64)SWR_OPERATION_CONTEXT_SYMBOL(5-5)SWROperationContext(7-11)packages/shared/src/types.ts (2)
InferAsyncIterableYield(18-18)ThrowableError(16-16)packages/shared/src/iterator.ts (2)
isAsyncIteratorObject(6-12)next(60-62)
🪛 LanguageTool
packages/react-swr/README.md
[grammar] ~41-~41: There might be a mistake here.
Context: ...h plugins, middleware, and interceptors. ## Documentation You can find the full docu...
(QB_NEW_EN)
[grammar] ~50-~50: There might be a mistake here.
Context: ...ackage/@orpc/server): Build your API or implement API contract. - [@orpc/client](https://...
(QB_NEW_EN)
[grammar] ~50-~50: There might be a mistake here.
Context: ...uild your API or implement API contract. - [@orpc/client](https://www.npmjs.com/pack...
(QB_NEW_EN)
[style] ~51-~51: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... your API or implement API contract. - [@orpc/client](https://www.npmjs.com/package/@...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~51-~51: There might be a mistake here.
Context: ...your API on the client with type-safety. - [@orpc/openapi](https://www.npmjs.com/pac...
(QB_NEW_EN)
[style] ~52-~52: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... API on the client with type-safety. - [@orpc/openapi](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~53-~53: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I specs and handle OpenAPI requests. - [@orpc/otel](https://www.npmjs.com/package/@or...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~54-~54: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ....io/) integration for observability. - [@orpc/nest](https://www.npmjs.com/package/@or...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~55-~55: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... with NestJS. - [@orpc/react](https://www.npmjs.com/package/@o...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...with React and React Server Actions. - [@orpc/tanstack-query](https://www.npmjs.com/p...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/vue-colada](https://www.npmjs.com/packa...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~58-~58: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ada](https://pinia-colada.esm.dev/). - [@orpc/hey-api](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~59-~59: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I](https://heyapi.dev/) integration. - [@orpc/zod](https://www.npmjs.com/package/@orp...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~60-~60: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...tps://zod.dev/) doesn't support yet. - [@orpc/valibot](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~61-~61: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rom Valibot. - [@orpc/arktype](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
apps/content/docs/integrations/react-swr.md
[grammar] ~171-~171: There might be a mistake here.
Context: ...rocedure client directly. It's an alias for corresponding procedure client. ```ts ...
(QB_NEW_EN)
🪛 markdownlint-cli2 (0.17.2)
packages/react-swr/README.md
71-71: Images should have alternate text (alt text)
(MD045, no-alt-text)
🪛 GitHub Check: test
packages/react-swr/tests/e2e.test.tsx
[failure] 112-112: packages/react-swr/tests/e2e.test.tsx > case: useSubscription & .liveSubscriber
AssertionError: expected [ { output: '1' }, { output: '2' } ] to be undefined
- Expected:
undefined
- Received:
[
{
"output": "1",
},
{
"output": "2",
},
]
❯ packages/react-swr/tests/e2e.test.tsx:112:44
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: lint
- GitHub Check: publish-commit
🔇 Additional comments (25)
apps/content/package.json (1)
19-19: LGTM: docs app now references the experimental SWR packageAdding
@orpc/experimental-react-swras a devDependency for the content app makes sense for local docs/examples.vitest.workspace.ts (1)
22-22: No DOM/React imports in.test.tsfiles—Node suite assignment is correctAll
.test.tsfiles underpackages/react-swrwere scanned. None import React or @testing-library/react, nor reference window, document, or navigator. Keeping them in the default Node suite and only using jsdom for*.test.tsxis intentional and appropriate.packages/shared/src/types.ts (1)
18-18: LGTM: useful utility for async-iterable yield extraction
InferAsyncIterableYield<T>is correct and will unblock precise typing for SSE/streaming utilities.packages/react-swr/package.json (1)
25-27: Exports mapping to TS source is safe in the workspaceI ran a search for any direct imports of
@orpc/experimental-react-swrin source files (excluding documentation) and found none—only a reference inapps/content/docs/integrations/react-swr.md. There are no runtime consumers in the monorepo that would break ifexports["."]points to./src/index.ts.Feel free to merge as-is.
packages/react-swr/src/index.test.ts (1)
1-3: LGTM: verifies public named export existsThe test correctly checks for the presence of the
createSWRUtilsnamed export on the public surface.apps/content/.vitepress/config.ts (1)
181-181: Docs sidebar entry looks goodThe Integrations sidebar entry for React SWR is consistent with existing items and link structure.
packages/react-swr/tsconfig.json (1)
1-16: LGTM: composite setup and source-only include are appropriateReferences to client/shared and exclusion of tests/benches align with the package’s build flow.
packages/react-swr/tests/shared.tsx (2)
4-5: LGTM: test utils are correctly wrapped
createSWRUtils(client)andcreateSWRUtils(streamedClient)usage looks correct and aligns with the public API.
2-2: Export wiring for createSWRUtils and test clients is correct
createSWRUtilsis re-exported inpackages/react-swr/src/index.tsorpcandstreamedOrpcare exported inpackages/react-swr/tests/shared.tsxAll symbols are available as expected.
packages/react-swr/src/general-utils.test.ts (1)
3-22: Solid coverage for matcher semanticsGood assertions for both partial and exact strategies, including undefined-input wildcard and path mismatch cases.
packages/react-swr/src/router-utils.test-d.ts (1)
9-38: Type surface checks look rightThe assertions accurately validate RouterUtils shape at root and nested levels, including error mapping for procedures and exclusion for routers.
packages/react-swr/src/general-utils.test-d.ts (2)
9-17: Good coverage for partial strategy (both optional and required inputs).Calls exercise shallow and deep partials correctly for the default 'partial' strategy on both optional and required variants.
30-33: Confirmed SWR v2+ Across All WorkspacesAll
swrentries in yourpackage.jsonfiles are pinned to version 2.x (found>=2.3.6and^2.3.6), so themutate(predicate)signature is supported and no updates are needed.packages/react-swr/src/index.ts (1)
1-6: Clear public surface; alias export is convenient.Re-exporting and aliasing createRouterUtils as createSWRUtils is a good DX choice. No naming collisions observed.
packages/react-swr/src/general-utils.ts (1)
12-32: Matcher logic is sound; exact vs partial handled correctly.
- Defaulting to 'partial' with subset checks is correct.
- The second subset check enforces exactness cleanly.
- Using satisfies Key ensures shape correctness without affecting runtime.
No changes needed.
packages/react-swr/src/procedure-utils.test-d.ts (2)
14-20: Type-level surface looks consistent and thoroughThe generics and expected behaviors for optional vs. required input, async-iterable streaming outputs, and error typing align with ProcedureUtils and the shared types. The assertions cover keys, fetchers, subscribers, live subscribers, and mutators well.
Also applies to: 21-27, 28-34
71-77: Note on SWR key typing limitationThe FIXME accurately documents SWR’s lack of key type enforcement. Good to keep this here to prevent regressions if SWR changes in the future.
packages/react-swr/src/procedure-utils.ts (3)
48-53: Key construction looks solid.Correctly normalizes optional input and returns a stable, path-scoped key tuple.
65-115: Subscriber pipeline is robust.Good async iterator validation, sensible reset semantics, and bounded growth with maxChunks. Error forwarding respects abort state.
117-155: Live subscriber behavior is correct.Streams events via next, verifies iterator shape, and suppresses abort-related errors appropriately.
packages/react-swr/src/types.ts (5)
5-11: Operation symbol and context tagging are well-defined.Unique symbol + discriminated union is a solid approach for internal operation tagging.
16-27: Key options resolver is correct.Safely normalizes optional input across undefined-inclusive types.
53-64: Fetcher options resolver is appropriate.Context normalization covers both optional and required client contexts cleanly.
70-85: Subscriber typing matches usage.Options capture refetch behavior and chunk bounding; the subscriber contract aligns with swr/subscription’s
SWRSubscriptionOptions.Also applies to: 87-90
1-3: swr/subscription types verified (swr v^2.3.6 is present)
rgfoundimport … from 'swr/subscription'only inpackages/react-swr(code, tests, docs).packages/react-swr/package.jsonlists"swr": "^2.3.6", which includes theswr/subscriptionexport.No further action required.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces experimental React SWR integration for oRPC, providing typed utilities for data fetching, mutations, and subscriptions with SWR hooks. The integration follows the established pattern of other oRPC framework integrations and includes comprehensive testing and documentation.
- Complete React SWR integration package with typed keys, fetchers, mutators, and subscription utilities
- Comprehensive test coverage including unit tests, type tests, and end-to-end integration tests
- Documentation updates across all packages to include the new SWR integration
Reviewed Changes
Copilot reviewed 57 out of 58 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-swr/ | New experimental React SWR integration package with utilities, tests, and configuration |
| vitest.workspace.ts | Added test configuration for the new react-swr package |
| packages/*/README.md | Updated framework integrations list to include SWR across all package documentation |
| packages/shared/src/types.ts | Added InferAsyncIterableYield utility type for async iterable type inference |
| apps/content/ | Added React SWR integration documentation and navigation entry |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (4)
packages/react-swr/src/procedure-utils.ts (1)
85-90: Prevent user context from overriding the SWR operation type (spread order bug).Spread
...contextfirst and then set[SWR_OPERATION_CONTEXT_SYMBOL]so callers cannot override the operation tag.Apply this diff in all four places:
@@ - return async ([, { input }]) => client(input, { - context: { - [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'fetcher' }, - ...context, - } satisfies SWROperationContext, - }) + return async ([, { input }]) => client(input, { + context: { + ...context, + [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'fetcher' }, + } satisfies SWROperationContext, + })@@ - const iterator = await client(input, { - context: { - [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'subscriber' }, - ...context, - } satisfies SWROperationContext, - signal: controller.signal, - }) + const iterator = await client(input, { + context: { + ...context, + [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'subscriber' }, + } satisfies SWROperationContext, + signal: controller.signal, + })@@ - const iterator = await client(input, { - context: { - [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'liveSubscriber' }, - ...context, - } satisfies SWROperationContext, - signal: controller.signal, - }) + const iterator = await client(input, { + context: { + ...context, + [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'liveSubscriber' }, + } satisfies SWROperationContext, + signal: controller.signal, + })@@ - return (_key, { arg }) => client(arg, { - context: { - [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'mutator' }, - ...context, - } satisfies SWROperationContext, - }) + return (_key, { arg }) => client(arg, { + context: { + ...context, + [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'mutator' }, + } satisfies SWROperationContext, + })Also applies to: 101-107, 153-159, 188-193
packages/react-swr/README.md (2)
64-66: LGTM: Section header matches the experimental package nameHeader is consistent with package.json and npm.
2-2: Fix invalid HTML tag: use, not
<image>is not a valid HTML element in Markdown; the logo may not render.Apply this diff:
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> + <img align="center" src="https://orpc.unnoq.com/logo.webp" width="280" alt="oRPC logo" />apps/content/docs/integrations/react-swr.md (1)
182-201: Add missing import for RPCLink in Operation Context exampleThe sample uses
RPCLinkbut doesn’t import it, making copy-paste usage fail.Apply this diff to include the import:
+import { RPCLink } from '@orpc/client' import { SWR_OPERATION_CONTEXT_SYMBOL, SWROperationContext, } from '@orpc/experimental-react-swr'
🧹 Nitpick comments (28)
packages/react-swr/src/procedure-utils.ts (2)
93-97: Validate and clamp maxChunks to a positive integer to avoid edge cases (e.g., 0 or negative).Currently, maxChunks=0 or negative yields empty arrays via slice behavior. Clamp to a positive integer for predictable semantics.
Apply this diff:
@@ - const { context, maxChunks, refetchMode = 'reset' } = resolveCreateFetcherOptions(resolveMaybeOptionalOptions(rest)) + const { context, maxChunks, refetchMode = 'reset' } = resolveCreateFetcherOptions(resolveMaybeOptionalOptions(rest)) + const effectiveMaxChunks = (typeof maxChunks === 'number' && Number.isFinite(maxChunks) && maxChunks > 0) + ? Math.floor(maxChunks) + : undefined @@ - if (typeof maxChunks === 'number' && newData.length > maxChunks) { - return newData.slice(newData.length - maxChunks) - } + if (effectiveMaxChunks !== undefined && newData.length > effectiveMaxChunks) { + return newData.slice(-effectiveMaxChunks) + }Also applies to: 121-123
109-111: Use more descriptive error messages to aid debugging.Include the procedure path in the error for quicker diagnosis.
Apply this diff:
- throw new Error('.subscriber requires an event iterator output') + throw new TypeError(`.subscriber for "${options.path.join('.')}" requires an event iterator output`)- throw new Error('.liveSubscriber requires an event iterator output') + throw new TypeError(`.liveSubscriber for "${options.path.join('.')}" requires an event iterator output`)Also applies to: 161-163
apps/content/index.md (1)
36-36: Unify phrasing with other READMEs and remove “etc.”Suggestion to keep this line consistent with other READMEs and avoid “etc.” for tighter copy.
Apply this diff:
- details: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular, etc.), SWR, Pinia Colada, NestJS, and more. + details: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.Optional: If the homepage supports markdown in this field, consider linking SWR to the new docs page for discoverability:
- Change “SWR” to “SWR”
Please verify whether links are rendered in thefeatures.detailsfield before applying.packages/react-query/README.md (2)
34-34: Add an “experimental” qualifier next to SWR for expectation management.Since the package is explicitly experimental, consider reflecting that in the Highlights list too.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.
57-57: @orpc/experimental-react-swr is published on npm (v0.0.0)✅ Validated:
@orpc/experimental-react-swrexists in the registry with latest tag 0.0.0, so the current README link will not 404.Optional recommendation:
- Pin the version in your docs to guard against future breaking changes. For example, in packages/react-query/README.md:
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): SWR integration. + [@orpc/experimental-react-swr@0.0.0](https://www.npmjs.com/package/@orpc/experimental-react-swr/v/0.0.0): SWR integration.packages/arktype/README.md (1)
34-34: Mirror “experimental” status in Highlights where SWR is listed.Keep messaging consistent with the package name indicating experimental status.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.packages/tanstack-query/README.md (1)
34-34: Clarify that SWR is experimental in the integrations list.Minor wording tweak to set expectations.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.packages/solid-query/README.md (1)
34-34: Note SWR’s experimental status in Highlights.Consistent wording across READMEs helps avoid confusion.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.packages/interop/README.md (1)
37-37: Tag SWR as experimental in the integrations list.Small clarity improvement to reflect the experimental nature here too.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.packages/server/README.md (1)
34-34: Clarify SWR is React-specific in the integrations list (optional).To reduce ambiguity for readers from non-React ecosystems, consider calling out SWR as “SWR (React)” alongside the other frameworks.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (React), Pinia Colada, and more.packages/valibot/README.md (1)
34-34: Optional wording tweak: specify SWR (React) to avoid ecosystem ambiguity.- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (React), Pinia Colada, and more.packages/svelte-query/README.md (1)
34-34: Minor clarity improvement: mark SWR as React.- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (React), Pinia Colada, and more.packages/vue-colada/README.md (1)
34-34: Optional: clarify SWR is for React.- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (React), Pinia Colada, and more.packages/contract/README.md (1)
34-34: Tiny clarity tweak: label SWR as React.- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (React), Pinia Colada, and more.packages/hey-api/README.md (1)
57-57: Clarify experimental status and link to docsSince the package name is prefixed with experimental, consider surfacing that in the description and linking to the integration docs for quick discovery.
Apply this diff:
-- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. +- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration (experimental). [Docs](https://orpc.unnoq.com/docs/integrations/react-swr)packages/otel/README.md (1)
57-57: Expose experimental status and docs linkSmall DX improvement: call out that this is experimental and add a direct link to the integration docs.
-- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. +- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration (experimental). [Docs](https://orpc.unnoq.com/docs/integrations/react-swr)packages/shared/README.md (1)
57-57: Add “experimental” note + docs link for discoverabilityMirroring other entries with a docs link helps users jump directly to usage.
-- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. +- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration (experimental). [Docs](https://orpc.unnoq.com/docs/integrations/react-swr)packages/react/README.md (1)
57-57: Surface experimental status and add docs linkAlign the package entry with the new docs page for faster onboarding.
-- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. +- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration (experimental). [Docs](https://orpc.unnoq.com/docs/integrations/react-swr)packages/json-schema/README.md (1)
57-57: Note experimental status and link docs for contextHelps set expectations and improves navigation.
-- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. +- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration (experimental). [Docs](https://orpc.unnoq.com/docs/integrations/react-swr)packages/openapi-client/README.md (1)
34-34: Consider linking SWR in Highlights for quick discoverability.Small UX win: link SWR to its docs like elsewhere in the repo.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), [SWR](https://swr.vercel.app/), Pinia Colada, and more.packages/standard-server/README.md (1)
34-34: Optional: add a link to SWR in Highlights for parity with other linked items.Keeps navigability consistent with other docs references in the repo.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), [SWR](https://swr.vercel.app/), Pinia Colada, and more.packages/standard-server-node/README.md (1)
34-34: Minor doc polish: link SWR in Highlights.Aligns with the linked references pattern and improves reader flow.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), [SWR](https://swr.vercel.app/), Pinia Colada, and more.packages/client/README.md (1)
34-34: Optional: hyperlink SWR in the integrations bullet.Consistent with other docs and helps readers jump to SWR quickly.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), [SWR](https://swr.vercel.app/), Pinia Colada, and more.packages/standard-server-peer/README.md (1)
34-34: Suggestion: add SWR link in Highlights for consistency.Tiny consistency improvement; safe to skip if you prefer minimal links in Highlights.
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), [SWR](https://swr.vercel.app/), Pinia Colada, and more.apps/content/docs/integrations/react-swr.md (1)
171-172: Minor grammar: add “the”Reads more naturally with the article.
-Use `.call` to call a procedure client directly. It's an alias for corresponding procedure client. +Use `.call` to call a procedure client directly. It's an alias for the corresponding procedure client.README.md (1)
34-34: Clarify experimental status inline in Highlights.Since the package is explicitly experimental, consider flagging SWR as experimental here to set expectations.
Apply this diff:
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.packages/nest/README.md (2)
34-34: Flag SWR as experimental in “Framework Integrations.”Mirror the package status to avoid confusion for Nest users scanning integrations.
Apply this diff:
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more. + - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR (experimental), Pinia Colada, and more.
57-57: Update README to mark @orpc/experimental-react-swr as experimental
- Verified on npm registry: HTTP 200, dist-tag “latest” → 0.0.0 (published 2025-08-18).
- Edit
packages/nest/README.md(line 57) to clarify experimental status.- - [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. + - [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr) (experimental): [SWR](https://swr.vercel.app/) integration.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (36)
README.md(2 hunks)apps/content/docs/integrations/react-swr.md(1 hunks)apps/content/index.md(1 hunks)packages/arktype/README.md(2 hunks)packages/client/README.md(2 hunks)packages/contract/README.md(2 hunks)packages/durable-event-iterator/README.md(2 hunks)packages/hey-api/README.md(2 hunks)packages/interop/README.md(2 hunks)packages/json-schema/README.md(2 hunks)packages/nest/README.md(2 hunks)packages/openapi-client/README.md(2 hunks)packages/openapi/README.md(2 hunks)packages/otel/README.md(2 hunks)packages/react-query/README.md(2 hunks)packages/react-swr/README.md(1 hunks)packages/react-swr/src/general-utils.ts(1 hunks)packages/react-swr/src/procedure-utils.ts(1 hunks)packages/react-swr/src/router-utils.ts(1 hunks)packages/react-swr/tests/e2e.test.tsx(1 hunks)packages/react/README.md(2 hunks)packages/server/README.md(2 hunks)packages/shared/README.md(2 hunks)packages/solid-query/README.md(2 hunks)packages/standard-server-aws-lambda/README.md(2 hunks)packages/standard-server-fetch/README.md(2 hunks)packages/standard-server-node/README.md(2 hunks)packages/standard-server-peer/README.md(2 hunks)packages/standard-server/README.md(2 hunks)packages/svelte-query/README.md(2 hunks)packages/tanstack-query/README.md(2 hunks)packages/trpc/README.md(2 hunks)packages/valibot/README.md(2 hunks)packages/vue-colada/README.md(2 hunks)packages/vue-query/README.md(2 hunks)packages/zod/README.md(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/react-swr/src/general-utils.ts
- packages/react-swr/src/router-utils.ts
- packages/react-swr/tests/e2e.test.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react-swr/src/procedure-utils.ts (5)
packages/client/src/types.ts (1)
Client(26-28)packages/shared/src/args.ts (2)
MaybeOptionalOptions(1-3)resolveMaybeOptionalOptions(5-7)packages/react-swr/src/types.ts (11)
CreateKeyOptions(13-14)Key(33-33)CreateFetcherOptions(50-51)Fetcher(66-66)CreateSubscriberOptions(70-85)Subscriber(87-90)Mutator(68-68)resolveCreateKeyOptions(16-27)resolveCreateFetcherOptions(53-64)SWR_OPERATION_CONTEXT_SYMBOL(5-5)SWROperationContext(7-11)packages/shared/src/types.ts (2)
InferAsyncIterableYield(18-18)ThrowableError(16-16)packages/shared/src/iterator.ts (2)
isAsyncIteratorObject(6-12)next(60-62)
🪛 LanguageTool
packages/standard-server-node/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/trpc/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/solid-query/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/shared/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/vue-colada/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/durable-event-iterator/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/tanstack-query/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/arktype/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/svelte-query/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/zod/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/vue-query/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/nest/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/react-query/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/standard-server/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/standard-server-aws-lambda/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
apps/content/docs/integrations/react-swr.md
[grammar] ~171-~171: There might be a mistake here.
Context: ...rocedure client directly. It's an alias for corresponding procedure client. ```ts ...
(QB_NEW_EN)
packages/client/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/contract/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/hey-api/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/interop/README.md
[style] ~60-~60: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/json-schema/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/openapi-client/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/openapi/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/otel/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/react-swr/README.md
[grammar] ~41-~41: There might be a mistake here.
Context: ...h plugins, middleware, and interceptors. ## Documentation You can find the full docu...
(QB_NEW_EN)
[grammar] ~50-~50: There might be a mistake here.
Context: ...ackage/@orpc/server): Build your API or implement API contract. - [@orpc/client](https://...
(QB_NEW_EN)
[grammar] ~50-~50: There might be a mistake here.
Context: ...uild your API or implement API contract. - [@orpc/client](https://www.npmjs.com/pack...
(QB_NEW_EN)
[style] ~51-~51: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... your API or implement API contract. - [@orpc/client](https://www.npmjs.com/package/@...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~51-~51: There might be a mistake here.
Context: ...your API on the client with type-safety. - [@orpc/openapi](https://www.npmjs.com/pac...
(QB_NEW_EN)
[style] ~52-~52: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... API on the client with type-safety. - [@orpc/openapi](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~53-~53: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I specs and handle OpenAPI requests. - [@orpc/otel](https://www.npmjs.com/package/@or...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~54-~54: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ....io/) integration for observability. - [@orpc/nest](https://www.npmjs.com/package/@or...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~55-~55: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... with NestJS. - [@orpc/react](https://www.npmjs.com/package/@o...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...with React and React Server Actions. - [@orpc/tanstack-query](https://www.npmjs.com/p...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~58-~58: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ttps://swr.vercel.app/) integration. - [@orpc/vue-colada](https://www.npmjs.com/packa...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~59-~59: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ada](https://pinia-colada.esm.dev/). - [@orpc/hey-api](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~60-~60: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I](https://heyapi.dev/) integration. - [@orpc/zod](https://www.npmjs.com/package/@orp...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~61-~61: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...tps://zod.dev/) doesn't support yet. - [@orpc/valibot](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~62-~62: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rom Valibot. - [@orpc/arktype](https://www.npmjs.com/package/...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/react/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/server/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/standard-server-fetch/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/standard-server-peer/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
packages/valibot/README.md
[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/experimental-react-swr](https://www.npm...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: test
- GitHub Check: publish-commit
- GitHub Check: lint
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (37)
packages/react-swr/src/procedure-utils.ts (2)
76-80: LGTM: key generator is stable and fully typed.Using resolveMaybeOptionalOptions + resolveCreateKeyOptions to normalize input and return a path-scoped tuple is clean and SWR-friendly.
130-136: LGTM: error forwarding respects abort semantics.Gating next(error) on !signal.aborted prevents noisy errors during unmount/dispose. Solid attention to UX.
Also applies to: 171-175
packages/openapi/README.md (2)
34-34: Good addition: SWR mentioned among framework integrationsThe copy reads naturally and matches the tone used elsewhere. No issues from my side.
57-57: @orpc/experimental-react-swr availability verified
Package@orpc/experimental-react-swr@0.0.0is published on npm and the README link is valid. No further action needed.packages/trpc/README.md (2)
34-34: SWR callout in “Framework Integrations” reads wellThe addition aligns with the rest of the highlights list. Looks good.
57-57: Package list entry for SWR is consistentThe new package entry is consistent with the format of other entries.
packages/standard-server-fetch/README.md (2)
34-34: SWR addition acknowledgedClear and consistent with other package READMEs.
57-57: SWR package entry LGTMNaming and link match the rest of the ecosystem list.
packages/durable-event-iterator/README.md (2)
34-34: SWR mention in highlights is appropriateMatches the style used across the repo. No issues.
57-57: Ecosystem list updated with SWR—looks goodConsistent naming and linking, nothing to change.
packages/arktype/README.md (1)
57-57: ✅ Confirmed npm availability for experimental SWR integration
Verified that@orpc/experimental-react-swris published on npm (latest: 0.0.0), so the README link is valid and will not 404. No further action required.packages/tanstack-query/README.md (1)
57-57: ✅ npm package link verifiedThe npm link for
@orpc/experimental-react-swris valid (latest version 0.0.0), so no changes to the README are needed.packages/solid-query/README.md (1)
57-57: Verified: npm package is live
The package@orpc/experimental-react-swris published on npm (latest v0.0.0), so the README link will not 404.packages/interop/README.md (1)
60-60: NPM link verified for @orpc/experimental-react-swr
The package exists on npm (latest version: 0.0.0), so the README link is valid. No changes required.packages/server/README.md (1)
57-57: Package entry for SWR looks good.Name, link, and placement are consistent with the other package entries.
packages/valibot/README.md (1)
57-57: LGTM on the new package entry.Consistent formatting and correct target URLs.
packages/svelte-query/README.md (1)
57-57: SWR package addition is correct and consistent.packages/vue-colada/README.md (1)
57-57: New SWR package line looks good.Matches structure and style of adjacent entries.
packages/contract/README.md (1)
57-57: SWR package entry addition is accurate.packages/hey-api/README.md (1)
34-34: LGTM: SWR added to Framework IntegrationsThe callout correctly adds SWR alongside TanStack Query and Pinia Colada, with accurate links and casing.
packages/otel/README.md (1)
34-34: LGTM: SWR added to Framework IntegrationsConsistent wording and placement with other READMEs. Link targets look correct.
packages/shared/README.md (1)
34-34: LGTM: Framework Integrations bullet updatedSWR inclusion is clear and consistent across the repo’s READMEs.
packages/react/README.md (1)
34-34: LGTM: SWR now listed under Framework IntegrationsAccurate addition with correct branding and link.
packages/json-schema/README.md (1)
34-34: LGTM: Framework Integrations updated to include SWRConsistent phrasing across READMEs. No issues spotted.
packages/openapi-client/README.md (1)
57-57: LGTM: Package entry reads clearly and matches the new integration.The addition cleanly mirrors other package entries and includes the SWR docs link.
packages/standard-server/README.md (1)
57-57: LGTM: New SWR package reference is consistent across READMEs.Matches naming and linking conventions used elsewhere.
packages/standard-server-node/README.md (1)
57-57: LGTM: Accurate and consistent package entry.No issues spotted.
packages/client/README.md (1)
57-57: LGTM: SWR package entry is correctly added.Clear, consistent wording and links.
packages/standard-server-peer/README.md (1)
57-57: LGTM: New package line matches the established pattern.No further changes needed here.
packages/zod/README.md (2)
34-34: LGTM: SWR mention added to Framework IntegrationsThe addition reads well and aligns with the new integration.
57-58: LGTM: New package entry for experimental SWR integrationCorrect package name and links. Consistent with the rest of the repo changes.
packages/vue-query/README.md (2)
34-34: LGTM: SWR added to integrations listConsistent phrasing with other READMEs; no issues spotted.
57-58: LGTM: Added @orpc/experimental-react-swr to PackagesCorrect link and package name.
packages/react-swr/README.md (1)
11-13: LGTM: npm badge now points to experimental packageThe badge/link correctly uses
@orpc/experimental-react-swr.packages/standard-server-aws-lambda/README.md (2)
34-34: LGTM: SWR added to integrations listMatches wording used elsewhere; no issues.
57-58: LGTM: Added experimental React SWR package entryCorrect link and naming.
README.md (1)
57-57: Add experimental qualifier and confirm NPM publicationVerified that
@orpc/experimental-react-swris live on npm (HTTP 200, latest version 0.0.0 as of 2025-08-18). Update the README accordingly:- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration. + [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr) (experimental): [SWR](https://swr.vercel.app/) integration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
packages/react-swr/src/procedure-utils.ts (2)
92-92: Clarify destructuring with explicit placeholder for the path.The leading-comma pattern
([, { input }])is terse and harder to read. Name the first tuple element to improve clarity.- return ([,{ input }], { next }) => { + return ([_path, { input }], { next }) => {And similarly for the live subscriber:
- return ([,{ input }], { next }) => { + return ([_path, { input }], { next }) => {Also applies to: 144-144
81-86: Ensure SWR operation type cannot be overridden by user contextSpreading
...contextafter the default[SWR_OPERATION_CONTEXT_SYMBOL]allows callers to replace the operation tag and break downstream logic. To lock in the correct operation type, always spread usercontextfirst, then assign the symbol. Update all occurrences inpackages/react-swr/src/procedure-utils.ts:• Lines 81–86 (
fetcher)
• Lines 96–102 (subscriber)
• Lines 148–154 (liveSubscriber)
• Lines 184–189 (mutator)Example diff for the
fetchercase:-return async ([, { input }]) => client(input, { - context: { - [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'fetcher' }, - ...context, - } satisfies SWROperationContext, -}) +return async ([, { input }]) => client(input, { + context: { + ...context, + [SWR_OPERATION_CONTEXT_SYMBOL]: { type: 'fetcher' }, + } satisfies SWROperationContext, +})Apply the same reorder for
subscriber,liveSubscriber, andmutatorcontexts.
🧹 Nitpick comments (2)
packages/react-swr/src/procedure-utils.ts (2)
117-121: Guard against invalidmaxChunksand use simpler slice.If
maxChunksis 0 or negative, current logic is surprising. Alsoslice(-maxChunks)is simpler.- if (typeof maxChunks === 'number' && newData.length > maxChunks) { - return newData.slice(newData.length - maxChunks) - } + if ( + typeof maxChunks === 'number' && + Number.isFinite(maxChunks) && + maxChunks > 0 && + newData.length > maxChunks + ) { + return newData.slice(-maxChunks) + }
106-107: Include procedure path in error messages for easier debugging.Augment the thrown errors with
options.pathso consumers can trace the failing procedure quickly.- if (!isAsyncIteratorObject(iterator)) { - throw new Error('.subscriber requires an event iterator output') - } + if (!isAsyncIteratorObject(iterator)) { + throw new Error(`.subscriber requires an event iterator output (path: ${options.path.join('.')})`) + } @@ - if (!isAsyncIteratorObject(iterator)) { - throw new Error('.liveSubscriber requires an event iterator output') - } + if (!isAsyncIteratorObject(iterator)) { + throw new Error(`.liveSubscriber requires an event iterator output (path: ${options.path.join('.')})`) + }Also applies to: 158-159
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
packages/react-swr/src/procedure-utils.test-d.ts(1 hunks)packages/react-swr/src/procedure-utils.ts(1 hunks)packages/react-swr/tests/e2e.test-d.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/react-swr/tests/e2e.test-d.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/react-swr/src/procedure-utils.test-d.ts (4)
packages/contract/src/error.ts (1)
ErrorFromErrorMap(49-49)packages/contract/tests/shared.ts (1)
baseErrorMap(12-17)packages/react-swr/src/procedure-utils.ts (1)
ProcedureUtils(11-63)packages/client/src/types.ts (1)
Client(26-28)
packages/react-swr/src/procedure-utils.ts (5)
packages/client/src/types.ts (1)
Client(26-28)packages/shared/src/args.ts (2)
MaybeOptionalOptions(1-3)resolveMaybeOptionalOptions(5-7)packages/react-swr/src/types.ts (11)
CreateKeyOptions(13-14)Key(33-33)CreateFetcherOptions(50-51)Fetcher(66-66)CreateSubscriberOptions(70-85)Subscriber(87-90)Mutator(68-68)resolveCreateKeyOptions(16-27)resolveCreateFetcherOptions(53-64)SWR_OPERATION_CONTEXT_SYMBOL(5-5)SWROperationContext(7-11)packages/shared/src/types.ts (1)
InferAsyncIterableYield(18-18)packages/shared/src/iterator.ts (2)
isAsyncIteratorObject(6-12)next(60-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: lint
- GitHub Check: test
- GitHub Check: publish-commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
♻️ Duplicate comments (1)
apps/content/docs/integrations/react-swr.md (1)
182-204: Add missing import for RPCLink in Operation Context example.The snippet uses
new RPCLinkbut doesn’t import it, which breaks copy‑paste.Apply this diff:
```ts +import { RPCLink } from '@orpc/client' import { SWR_OPERATION_CONTEXT_SYMBOL, SWROperationContext, } from '@orpc/experimental-react-swr' interface ClientContext extends SWROperationContext { } const GET_OPERATION_TYPE = new Set(['fetcher', 'subscriber', 'liveSubscriber']) const link = new RPCLink<ClientContext>({ url: 'http://localhost:3000/rpc', method: ({ context }, path) => { const operationType = context[SWR_OPERATION_CONTEXT_SYMBOL]?.type
🧹 Nitpick comments (1)
apps/content/docs/integrations/react-swr.md (1)
61-68: Remove placeholder twoslash comment lines to reduce noise.These standalone
//lines add visual clutter without value.Apply this diff:
-// - -// - -// - -//
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/content/docs/integrations/react-swr.md(1 hunks)
🧰 Additional context used
🪛 LanguageTool
apps/content/docs/integrations/react-swr.md
[grammar] ~171-~171: There might be a mistake here.
Context: ...rocedure client directly. It's an alias for corresponding procedure client. ```ts ...
(QB_NEW_EN)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: publish-commit
- GitHub Check: lint
- GitHub Check: test
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/content/docs/integrations/react-swr.md (1)
6-12: Clear, concise intro that aligns with the new API surface.Good overview and expectation-setting with the SWR prerequisite. Examples map well to the new utilities.
Closes: https://github.com/unnoq/orpc/discussions/251
Summary by CodeRabbit
New Features
Documentation
Tests
Chores