Skip to content

feat(client): add React hooks — createCorsairReactClient()#263

Open
yuvrxj-afk wants to merge 4 commits into
corsairdev:mainfrom
yuvrxj-afk:feat/management-client-react
Open

feat(client): add React hooks — createCorsairReactClient()#263
yuvrxj-afk wants to merge 4 commits into
corsairdev:mainfrom
yuvrxj-afk:feat/management-client-react

Conversation

@yuvrxj-afk

Copy link
Copy Markdown
Contributor

Stacked on #250 — diff will clean up once that lands.

Summary

  • Adds createCorsairReactClient({ baseURL }) — factory returning typed React hooks over the vanilla createCorsairClient.
  • Hooks: useTenants, useTenant, useCreateTenant, usePlugins, usePlugin, useConnectionStatus, usePermission, usePermissionByToken, useCreateConnectLink, useOAuthCallback, plus the underlying client as an escape hatch.
  • Two internal primitives — useAsync(fn, deps) for reads (idle → loading → success | error, with refetch) and useMutation(fn) for writes (stays idle until mutate(input)).
  • Closes the management-client work for Feature: Create Corsair Client #241.

Notes

  • React is a peer dep (>=18), not a hard dep. Vanilla client still works without React.
  • jsdom test environment added for the React hook tests only (tests/setup-jsdom-fetch.cjs polyfills fetch under jsdom).
  • Docs will land in a follow-up PR off main once feat(core): add connect and OAuth callback routes #250 and this merge.

Test plan

  • 16 new tests in management-react-client.test.ts — loading/error/success states, refetch, re-fetch on dep change, mutation lifecycle
  • Full suite passes

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@yuvrxj-afk is attempting to deploy a commit to the corsair Team on Vercel.

A member of the Team first needs to authorize it.

@devjain32 devjain32 marked this pull request as ready for review June 16, 2026 22:16
@github-actions github-actions Bot added the core label Jun 16, 2026
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Review completed and submitted via the Greptile review tools.

Confidence Score: 5/5

Safe to merge — core hooks are correct, race condition addressed, all tests pass.

No blocking issues found. Remaining items are non-blocking cleanup.

packages/corsair/client/react/index.ts

Reviews (4): Last reviewed commit: "fix(test): wire setup-jsdom-fetch.cjs in..." | Re-trigger Greptile

Comment thread packages/corsair/client/react/index.ts
Comment thread packages/corsair/client/react/index.ts
@yuvrxj-afk yuvrxj-afk force-pushed the feat/management-client-react branch from 05c7a4a to d60bf30 Compare June 17, 2026 21:16
@yuvrxj-afk

yuvrxj-afk commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread packages/corsair/tests/setup-jsdom-fetch.cjs
@devjain32

Copy link
Copy Markdown
Contributor

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants