sannajammeh / trpc-swr

tRPC-ified SWR hooks
https://trpc-swr.vercel.app
MIT License
209 stars 5 forks source link

V3 - Better SSR support for Next 14, refactor from deprecated tRPC apis #54

Closed sannajammeh closed 9 months ago

sannajammeh commented 9 months ago

What:

@trpc-swr/ssr - createProxySSGHelpers renamed to createSSRHelpers

@trpc-swr/ssr - Calling api.endpoint.fetch is no longer support, use api.endpoint() directly. trpc-swr will now proxy all arguments directly into appRouter.createCaller() instead of calling caller.query. This allows for both mutations and queries to endpoints in React Server Components and other SSR calls

Before

const data = await rsc.users.byId.fetch({ id: 1 });

const swrFallback = await rsc.dehydrate();

After

const data = await rsc.users.byId({ id: 1 });

// Other supported methods:
const key = rsc.users.byId.getKey(); // Use to manually forward to SWRConfig.
const swrFallback = await rsc.dehydrate();

As always both direct access and dehydration into SWR serializable fallback is supported.

changeset-bot[bot] commented 9 months ago

🦋 Changeset detected

Latest commit: 5b020a2a9d01e86d125eee33192f025ce7e35462

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages | Name | Type | | ------------------ | ----- | | @trpc-swr/infinite | Major | | @trpc-swr/client | Major | | @trpc-swr/next | Major | | @trpc-swr/ssr | Major |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 9 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment | Name | Status | Preview | Updated (UTC) | | :--- | :----- | :------ | :------ | | **trpc-swr** | ⬜️ Ignored ([Inspect](https://vercel.com/sannajammeh/trpc-swr/J4MiFqATJwEeGZkn6o8T6az2QmRR)) | | Nov 24, 2023 8:47pm |