fix(create): use shared router factory in router-only apps #481
main fromrefs/pull/481/head·merged by tannerlinsley React and Solid router-only apps now call the shared getRouter() factory, so router customizations apply and the Register declaration stays in one place.
Adding Query to either framework wraps the router with its browser Query provider and uses the same query client as router context. React router-only output no longer imports the Start SSR integration. The add command also lets pnpm update the lockfile after intentionally changing dependencies, including in CI.
Validation:
- Repository build and 456 unit tests passed.
- Four affected browser cases generated apps outside the monorepo, installed dependencies, built and type-checked both frameworks, and verified custom router settings and Query results.
- The normal pre-commit build, unit and eight blocking browser checks passed.
Summary by CodeRabbit#
- New Features
- Router-only React and Solid apps now use consistent router setup, with router type support available in the router configuration.
- Adding TanStack Query to a router-only app now provides query access in the browser without requiring server-rendering integration.
- Bug Fixes
- Adding dependencies to an existing app with pnpm can now update the lockfile in CI instead of failing because of frozen-lockfile settings.
- 1
🧹 Nitpick comments (1)
packages/create/tests/framework-template.test.ts (1)
73-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the
RouterProviderpackage import too.These expectations would still pass if
main.tsximportedRouterProviderfrom the wrong framework package. Adding that assertion closes the cross-framework contract gap.Suggested test addition
expect(main).toContain(getRouterImport) + expect(main).toContain( + `import { RouterProvider } from '${routerPackage}'`, + ) expect(main).toContain('const router = getRouter()')🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/create/tests/framework-template.test.ts` around lines 73 - 99, The router-only entry test in framework-template.test.ts is missing an assertion for the RouterProvider import source, so it could still pass with the wrong framework package. Update the renderRouterOnlyEntries expectations in the shared router factory test to also verify the main entry imports RouterProvider from the correct framework-specific package, alongside the existing getRouter, createRouter, and declare module checks.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@packages/create/tests/framework-template.test.ts`: - Around line 73-99: The router-only entry test in framework-template.test.ts is missing an assertion for the RouterProvider import source, so it could still pass with the wrong framework package. Update the renderRouterOnlyEntries expectations in the shared router factory test to also verify the main entry imports RouterProvider from the correct framework-specific package, alongside the existing getRouter, createRouter, and declare module checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
ffe9213f-35bd-4052-9e3d-b73028fe98b1📥 Commits
Reviewing files that changed from the base of the PR and between 12c31dfb429ec057af9ddc5f85f492b0b0b22979 and 58370320bc6747fd91f5c25b09dd79e5166545e8.
📒 Files selected for processing (3)
packages/create/src/frameworks/react/project/base/src/main.tsx.ejspackages/create/src/frameworks/solid/project/base/src/main.tsx.ejspackages/create/tests/framework-template.test.ts
🦋 Changeset detected#
Latest commit: b99bf948a5e652829e79f59cea5caf39f3a3393f
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 7 packages
Name Type @tanstack/create Patch create-start-app Patch create-tanstack-app Patch create-tanstack Patch create-tsrouter-app Patch @tanstack/create-start Patch @tanstack/cli Patch 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
The Query repair is now pushed for both frameworks. Generated-app checks and the normal local gates passed at b99bf948, and this updated head is waiting for CI and review.
tannerlinsley merged thisfcff1bf
tannerlinsley closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review.
4916c573-1952-4e8f-ab16-737de35aaddaReviewing files that changed from the base of the PR and between e4b8ef506bcdfbcdf75f2bc9d06143d68a4dfe6a and b99bf948a5e652829e79f59cea5caf39f3a3393f.
.changeset/shared-router-factory.mdpackages/cli/tests-e2e/helpers.tspackages/cli/tests-e2e/shared-router-factory.spec.tspackages/create/src/add-to-app.tspackages/create/src/frameworks/react/project/base/src/router.tsx.ejspackages/create/src/frameworks/solid/project/base/src/router.tsx.ejspackages/create/src/package-manager.tspackages/create/tests/framework-template.test.tspackages/create/tests/package-manager.test.tsIncluded review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Walkthrough
React and Solid router-only templates now initialize through
getRouter()and configure Query providers without SSR query integration. Tests cover generated templates and router-only app behavior. The add-to-app installation path can update pnpm lockfiles when it installs dependencies.Changes: Router-only templates and Query
packages/create/src/frameworks/react/project/base/src/main.tsx.ejs,packages/create/src/frameworks/solid/project/base/src/main.tsx.ejsgetRouter()instead of constructing the router inline. They remove the local router type augmentation.packages/create/src/frameworks/react/project/base/src/router.tsx.ejs,packages/create/src/frameworks/solid/project/base/src/router.tsx.ejsQueryClientProviderand skips SSR query integration in router-only mode. Solid passes Query context into the router and providescontext.queryClientin router-only mode.packages/create/tests/framework-template.test.ts,packages/cli/tests-e2e/shared-router-factory.spec.ts,packages/cli/tests-e2e/helpers.ts,.changeset/shared-router-factory.md--forcedto the add command.pnpm lockfile updates
packages/create/src/add-to-app.ts,packages/create/src/package-manager.ts,packages/create/tests/package-manager.test.ts,.changeset/shared-router-factory.md--no-frozen-lockfile; npm install arguments remain unchanged. Tests cover these cases.Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Suggested reviewers:
tannerlinsley,brenelz,symindMerge Risk:
Minimal · up to
b99bfRouter-only apps use the shared factory and Query providers. No merge-blocking issue was identified.
Pre-merge checks:
3 · 
2
#480]. The PR also changes Query provider generation, SSR Query imports, package-manager lockfile behavior, the add-on test helper, and related tests and release n…#480] by removing the unrelated Query, lockfile, add-on helper, and associated production and test changes, or provide the active linked issue requirements that explicitly cover those changes.#480] requires router-only React and Solidmain.tsxtemplates to import and callgetRouter()fromrouter.tsx. The whole-PR diff shows both templates make this change and remove inline rou…Full details: Linked Issues check
Explanation
Issue [
#480] requires router-only React and Solidmain.tsxtemplates to import and callgetRouter()fromrouter.tsx. The whole-PR diff shows both templates make this change and remove inline router creation. The templates also remove the duplicateRegisterdeclarations frommain.tsx.router.tsx.ejskeeps the factory and the singleRegisterdeclaration. Template tests cover both frameworks and the end-to-end tests verify factory configuration at runtime.Full details: Out of Scope Changes check
Explanation
The supplied active linked issue is [
#480]. The PR also changes Query provider generation, SSR Query imports, package-manager lockfile behavior, the add-on test helper, and related tests and release notes. These changes have no concrete connection to#480, which only requires the shared router factory and the singleRegisterdeclaration. The PR description mentions#522, but no linked-issue requirements for#522are supplied for this assessment.Resolution
Keep this PR limited to [
#480] by removing the unrelated Query, lockfile, add-on helper, and associated production and test changes, or provide the active linked issue requirements that explicitly cover those changes.Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 6 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate unit tests (beta)
Warning
Some tools did not complete. Review the errors below.
packages/cli/tests-e2e/helpers.ts
Parsing error: "parserOptions.project" has been provided for
@typescript-eslint/parser. The file was not found in any of the provided project(s): packages/cli/tests-e2e/helpers.tspackages/cli/tests-e2e/shared-router-factory.spec.ts
Parsing error: "parserOptions.project" has been provided for
@typescript-eslint/parser. The file was not found in any of the provided project(s): packages/cli/tests-e2e/shared-router-factory.spec.tspackages/create/tests/framework-template.test.ts
Parsing error: "parserOptions.project" has been provided for
@typescript-eslint/parser. The file was not found in any of the provided project(s): packages/create/tests/framework-template.test.tsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share