-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from sannajammeh/better-ssr
V3 - Better SSR support for Next 14, refactor from deprecated tRPC apis
- Loading branch information
Showing
30 changed files
with
2,924 additions
and
4,044 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"mode": "pre", | ||
"tag": "canary", | ||
"initialVersions": { | ||
"app-dir": "0.1.0", | ||
"demo": "0.1.0", | ||
"docs": "0.0.1", | ||
"@trpc-swr/client": "2.0.1", | ||
"config": "1.0.0", | ||
"@trpc-swr/infinite": "2.0.1", | ||
"@trpc-swr/next": "2.0.1", | ||
"@trpc-swr/ssr": "2.0.1", | ||
"e2e": "1.0.0", | ||
"unit": "1.0.0" | ||
}, | ||
"changesets": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
"@trpc-swr/infinite": major | ||
"@trpc-swr/client": major | ||
"@trpc-swr/next": major | ||
"@trpc-swr/ssr": major | ||
--- | ||
|
||
## 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 | ||
|
||
```tsx | ||
const data = await rsc.users.byId.fetch({ id: 1 }); | ||
|
||
const swrFallback = await rsc.dehydrate(); | ||
``` | ||
|
||
#### After | ||
|
||
```tsx | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
experimental: { | ||
appDir: true, | ||
}, | ||
reactStrictMode: true, | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.