-
Notifications
You must be signed in to change notification settings - Fork 255
Add SSR DbClient and live query identity #1564
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
Open
tannerlinsley
wants to merge
25
commits into
main
Choose a base branch
from
codex/ssr-db-client-live-query-identity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
df004ef
Add SSR DbClient and live query identity
tannerlinsley 20923c9
Add SSR DbClient and live query identity
tannerlinsley 43b69e7
Remove Claude worktree from SSR PR
tannerlinsley bf8e768
Fix SSR PR after main merge
tannerlinsley 3d45726
ci: apply automated fixes
autofix-ci[bot] 6af77a2
Tighten SSR collection identity
tannerlinsley 53504fb
Add SSR hydration round trip test
tannerlinsley cef8b28
Add Start SSR hydration E2E
tannerlinsley 87fc258
Add SSR launch docs and demo
tannerlinsley 62e94c4
ci: apply automated fixes
autofix-ci[bot] 5753327
fix: harden SSR client behavior
tannerlinsley 9ee3229
chore: format SSR type tests
tannerlinsley 6a81849
feat: stream suspense DB queries during SSR
tannerlinsley 43d4723
Merge remote-tracking branch 'origin/main' into codex/ssr-db-client-l…
tannerlinsley eeb2ad6
Merge remote-tracking branch 'origin/main' into codex/ssr-db-client-l…
tannerlinsley affaf51
Merge remote-tracking branch 'origin/main' into codex/ssr-db-client-l…
tannerlinsley 97abc40
fix: address SSR review regressions
tannerlinsley 20978da
feat: stream SSR live query result snapshots
tannerlinsley 2dae48a
ci: apply automated fixes
autofix-ci[bot] e6a1d2e
chore: ignore generated Next.js types
tannerlinsley a0b63f7
fix: settle SSR hydration edge cases
tannerlinsley 376a829
ci: apply automated fixes
autofix-ci[bot] e55599f
fix: address SSR hydration review findings
tannerlinsley 6ea21fc
test: type SSR observer regressions
tannerlinsley 12cbc90
fix: ignore empty live query keys
tannerlinsley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| '@tanstack/db': minor | ||
| '@tanstack/react-db': minor | ||
| '@tanstack/svelte-db': minor | ||
| '@tanstack/react-router-with-db': minor | ||
| '@tanstack/electric-db-collection': minor | ||
| '@tanstack/query-db-collection': patch | ||
| '@tanstack/powersync-db-collection': patch | ||
| '@tanstack/rxdb-db-collection': patch | ||
| '@tanstack/trailbase-db-collection': patch | ||
| '@tanstack/db-sqlite-persistence-core': patch | ||
| --- | ||
|
|
||
| Add SSR through request-scoped `DbClient` instances, collection descriptors, | ||
| explicit collection-row hydration, live-query result snapshots, adapter sync | ||
| metadata, and React and Svelte descriptor resolution. | ||
|
|
||
| React live queries now derive identity from structured query IR. Opaque queries | ||
| can provide `queryKey`; legacy dependency arrays and unkeyed opaque queries keep | ||
| working with development warnings until 1.0. | ||
|
|
||
| Add TanStack Router integration that streams live queries discovered during a | ||
| Suspense render as pending promises which resolve to ordered result snapshots. | ||
| The browser starts normal source sync and atomically replaces the snapshot when | ||
| its live result is ready. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # TanStack DB SSR Release Plan | ||
|
|
||
| ## Release Goal | ||
|
|
||
| Ship TanStack DB SSR as a single coherent story: | ||
|
|
||
| - explicit collection-row hydration and live-query result snapshots through | ||
| `DbClient` | ||
| - React and Svelte provider and descriptor resolution | ||
| - derived live query identity with `queryKey` only when necessary | ||
| - backwards-compatible dependency arrays with dev warnings until 1.0 | ||
| - a working TanStack Start demo and E2E proof | ||
|
|
||
| ## Pre-release Validation | ||
|
|
||
| - Run `pnpm --filter @tanstack/db test`. | ||
| - Run `pnpm --filter @tanstack/react-db test`. | ||
| - Run `pnpm --filter @tanstack/svelte-db test`. | ||
| - Run `pnpm --filter @tanstack/react-router-with-db test` (includes type | ||
| tests). | ||
| - Run `pnpm --filter @tanstack/query-db-collection test`. | ||
| - Run `pnpm --filter @tanstack/db-sqlite-persistence-core test`. | ||
| - Run `pnpm --filter @tanstack/db-example-react-start-ssr-e2e test:e2e`. | ||
| - Run `pnpm --filter @tanstack/db-example-react-next-ssr-e2e test:e2e`. | ||
| - Run `pnpm test:docs`. | ||
| - Run `pnpm test:sherif`. | ||
| - Run `pnpm build`. | ||
|
|
||
| ## Demo | ||
|
|
||
| - Live URL: https://tanstack-db-ssr-demo.netlify.app/ssr-db | ||
| - Deploy `examples/react/start-ssr-e2e` to an SSR-capable host. | ||
| - Verify the deployed `/ssr-db` route serves SSR HTML with hydrated rows. | ||
| - Verify browser hydration succeeds without console/page errors. | ||
| - Verify the streamed collection chunk updates the live query. | ||
| - Verify `/ssr-db-stream` streams a projected result, omits source-only data, | ||
| and hands off to browser sync. | ||
| - Run `PLAYWRIGHT_BASE_URL=https://tanstack-db-ssr-demo.netlify.app pnpm --filter @tanstack/db-example-react-start-ssr-e2e test:e2e:hosted`. | ||
| - Add the live URL to the PR description and release notes. | ||
|
|
||
| ## Docs | ||
|
|
||
| - Publish the [SSR and Hydration guide](../docs/guides/ssr.md). | ||
| - Link the guide from overview, quick start, live queries, and React overview. | ||
| - Regenerate API reference docs in a dedicated docs-maintenance pass if broad | ||
| TypeDoc output churn is acceptable. | ||
| - Confirm docs explain when `queryKey` is necessary and when it should be | ||
| omitted. | ||
| - Confirm docs say dependency arrays warn now and are removed in 1.0. | ||
|
|
||
| ## Migration Messaging | ||
|
|
||
| - Lead with: explicit collection preloads transport normalized rows; live-query | ||
| preloads transport only their result snapshot. | ||
| - Emphasize that existing apps keep working. | ||
| - State that `createCollection(...)` remains available, but SSR apps should use | ||
| `collectionOptions(...)` plus `DbClient`. | ||
| - Explain that React dependency arrays are deprecated with a 1.0 removal path. | ||
| - Show `queryKey` only for opaque functional query logic or hot render paths. | ||
|
|
||
| ## Announcement Checklist | ||
|
|
||
| - PR description includes high-level summary, migration cheat sheet, and test | ||
| commands. | ||
| - Release notes include a "No removals in this release" compatibility section. | ||
| - Discord announcement links the SSR guide and live demo. | ||
| - Example migration diff is available from the Start SSR demo. | ||
| - Follow-up issues are filed for the remaining framework adapters and API | ||
| reference generation if they are not part of the shipping PR. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: TanStack/db
Length of output: 1850
🏁 Script executed:
Repository: TanStack/db
Length of output: 33647
🏁 Script executed:
Repository: TanStack/db
Length of output: 9573
🏁 Script executed:
Repository: TanStack/db
Length of output: 3075
🌐 Web query:
Vitest official documentation typecheck.enabled --typecheck test-d.ts💡 Result:
In Vitest, the --typecheck flag is used to enable typechecking alongside your regular tests [1][2]. When enabled, Vitest utilizes tsc or vue-tsc (depending on your configuration) to verify types and report errors in both your source code and your type tests [2][3]. Key details regarding the --typecheck flag and .test-d.ts files: 1. Type Tests (.test-d.ts): Files ending with the.test-d.ts suffix are automatically recognized as type tests [2][4]. Within these files, you can use specialized testing utilities such as expectTypeOf and assertType to perform assertions on your types [2][5]. 2. Enabling Typechecking: You can enable this functionality by passing the --typecheck flag via the CLI when running your test script [2][4]: "scripts": { "test": "vitest --typecheck" } Alternatively, you can configure this in your vitest configuration file by setting typecheck.enabled: true [1][6]. 3. Behavior: When --typecheck is active, Vitest will perform typechecking of your source code and execute tests defined in *.test-d.ts files [2][3]. Note that if your project does not contain any *.test-d.ts files, Vitest may not perform full typechecking or report source code type errors; in such cases, creating an empty *.test-d.ts file is a common workaround to force the execution of the typechecker [7]. 4. Configuration: You can further customize the typechecking behavior using the typecheck configuration object in your Vitest config file, which includes options like typecheck.checker (to specify 'tsc' or 'vue-tsc'), typecheck.include, and typecheck.tsconfig [1][8].
Citations:
Add
@tanstack/react-router-with-dbvalidation to the release checklist.Add these commands:
pnpm --filter@tanstack/react-router-with-dbtestpnpm --filter@tanstack/react-router-with-dbexec vitest --run --typecheckThe second command runs
packages/react-router-with-db/tests/index.test-d.ts.🧰 Tools
🪛 LanguageTool
[style] ~18-~18: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...pm --filter
@tanstack/react-dbtest. - Runpnpm --filter@tanstack/svelte-dbtest...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~19-~19: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...m --filter
@tanstack/svelte-dbtest. - Runpnpm --filter@tanstack/query-db-colle...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~20-~20: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...
@tanstack/query-db-collectiontest. - Runpnpm --filter@tanstack/db-sqlite-pers...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~21-~21: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ack/db-sqlite-persistence-core test
. - Runpnpm --filter@tanstack/db-example-rea...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~21-~21: Ensure spelling is correct
Context: ...db-sqlite-persistence-core test
. - Runpnpm --filter@tanstack/db-example-react-start-ssr-e2etest:e2e. - Runpnpm --filter@tanstack/db-exam...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[style] ~22-~22: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...xample-react-start-ssr-e2e test:e2e
. - Runpnpm --filter@tanstack/db-example-rea...(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[grammar] ~22-~22: Ensure spelling is correct
Context: ...le-react-start-ssr-e2e test:e2e
. - Runpnpm --filter@tanstack/db-example-react-next-ssr-e2etest:e2e. - Runpnpm test:docs. - Runpnpm te...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents