Skip to content

Conversation

@birkskyum
Copy link
Member

@birkskyum birkskyum commented Nov 12, 2025

Summary by CodeRabbit

  • Documentation
    • Added a new Solid.js example demonstrating scroll restoration functionality with virtualized lists. The example includes a multi-route application showcasing scroll position restoration across navigation, with integration of a virtualized component for efficiently rendering large datasets while maintaining scroll state.

@github-actions github-actions bot added the documentation Everything documentation related label Nov 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

A new Solid.js example project demonstrating scroll restoration with TanStack Router is introduced. The example includes complete project setup with build tooling, configuration files, and a router implementation featuring scroll position preservation and virtual list rendering.

Changes

Cohort / File(s) Summary
Configuration and Documentation
docs/router/config.json
Added a new Scroll Restoration example entry pointing to the Solid router examples directory.
Project Configuration
examples/solid/scroll-restoration/package.json, tsconfig.json, vite.config.js, postcss.config.mjs
Established development environment with dependencies, TypeScript configuration for strict checking and Solid JSX support, Vite build setup with Solid plugin, and PostCSS configuration for Tailwind CSS integration.
Build and Editor Configuration
examples/solid/scroll-restoration/.gitignore, .vscode/settings.json
Configured version control exclusions and VSCode editor settings to exclude and mark the generated routeTree.gen.ts file as readonly.
Application Entry Point
examples/solid/scroll-restoration/index.html
Added minimal HTML document with root div and reference to Vite module entry.
Source Code
examples/solid/scroll-restoration/src/main.tsx, src/styles.css
Implemented multi-route Solid router with scroll restoration, virtualized list rendering via TanStack Virtual, and Tailwind CSS styling. Routes include index, about, and a "by-element" view demonstrating scroll position preservation on a large virtualized dataset.
Documentation
examples/solid/scroll-restoration/README.md
Added basic instructions for installing dependencies and running the example.

Sequence Diagram

sequenceDiagram
    participant User
    participant Router
    participant ScrollRestoration
    participant Virtualizer
    participant DOM

    User->>Router: Navigate to route
    Router->>ScrollRestoration: Initialize scroll restoration
    activate ScrollRestoration
    ScrollRestoration->>DOM: Capture current scroll position
    ScrollRestoration->>Router: Store scroll state
    deactivate ScrollRestoration
    
    Router->>User: Render new route
    
    User->>DOM: Scroll/interact with virtualized list
    Virtualizer->>DOM: Render visible items
    
    User->>Router: Navigate away
    activate ScrollRestoration
    ScrollRestoration->>DOM: Save scroll position to state
    deactivate ScrollRestoration
    
    User->>Router: Navigate back
    activate ScrollRestoration
    ScrollRestoration->>DOM: Restore saved scroll position
    deactivate ScrollRestoration
    Virtualizer->>DOM: Re-render from restored position
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Area of focus: src/main.tsx — Verify router initialization correctness, scroll restoration hook integration with the virtualizer, module augmentation pattern for router registration, and proper setup of the scroll container reference and useElementScrollRestoration usage.
  • Configuration validation: Ensure all build and TypeScript configurations align with project standards and Solid.js best practices.

Possibly related PRs

Suggested reviewers

  • schiller-manuel
  • brenelz

Poem

🐰 Hop along the scrolling trail, where positions don't fail,
A Solid router spins with care, virtual lists float through air,
From start to end, the scroll's restored with grace,
Rabbit-tested, router-blessed, this example takes its place! 🎡

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a scroll restoration example for Solid router. It is specific, concise, and directly reflects the primary purpose of the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs(solid-router)--scroll-restoration-example

Thanks 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Nov 12, 2025

View your CI Pipeline Execution ↗ for commit 26c6b4a

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 1m 7s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-12 18:10:06 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 12, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5839

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5839

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5839

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5839

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5839

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5839

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5839

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5839

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5839

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5839

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5839

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5839

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5839

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5839

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5839

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5839

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5839

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5839

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5839

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5839

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5839

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5839

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5839

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5839

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5839

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5839

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5839

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5839

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5839

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5839

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5839

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5839

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5839

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5839

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5839

commit: 26c6b4a

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
examples/solid/scroll-restoration/index.html (1)

6-6: Consider a more descriptive title.

The title "Vite App" is generic. Consider updating it to something more specific like "Scroll Restoration Example" to better describe the example's purpose.

Apply this diff:

-    <title>Vite App</title>
+    <title>Scroll Restoration Example</title>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb8318 and 26c6b4a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (11)
  • docs/router/config.json (1 hunks)
  • examples/solid/scroll-restoration/.gitignore (1 hunks)
  • examples/solid/scroll-restoration/.vscode/settings.json (1 hunks)
  • examples/solid/scroll-restoration/README.md (1 hunks)
  • examples/solid/scroll-restoration/index.html (1 hunks)
  • examples/solid/scroll-restoration/package.json (1 hunks)
  • examples/solid/scroll-restoration/postcss.config.mjs (1 hunks)
  • examples/solid/scroll-restoration/src/main.tsx (1 hunks)
  • examples/solid/scroll-restoration/src/styles.css (1 hunks)
  • examples/solid/scroll-restoration/tsconfig.json (1 hunks)
  • examples/solid/scroll-restoration/vite.config.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
examples/{react,solid}/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep example applications under examples/react/ and examples/solid/

Files:

  • examples/solid/scroll-restoration/README.md
  • examples/solid/scroll-restoration/vite.config.js
  • examples/solid/scroll-restoration/src/main.tsx
  • examples/solid/scroll-restoration/package.json
  • examples/solid/scroll-restoration/src/styles.css
  • examples/solid/scroll-restoration/postcss.config.mjs
  • examples/solid/scroll-restoration/index.html
  • examples/solid/scroll-restoration/tsconfig.json
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • examples/solid/scroll-restoration/src/main.tsx
docs/{router,start}/**

📄 CodeRabbit inference engine (AGENTS.md)

Place router docs under docs/router/ and start framework docs under docs/start/

Files:

  • docs/router/config.json
**/package.json

📄 CodeRabbit inference engine (AGENTS.md)

Use workspace:* protocol for internal dependencies in package.json files

Files:

  • examples/solid/scroll-restoration/package.json
🧠 Learnings (8)
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/

Applied to files:

  • examples/solid/scroll-restoration/src/main.tsx
  • examples/solid/scroll-restoration/package.json
  • examples/solid/scroll-restoration/tsconfig.json
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to packages/{router-cli,router-generator,router-plugin,virtual-file-routes}/** : Keep CLI, generators, bundler plugins, and virtual file routing utilities in their dedicated tooling package directories

Applied to files:

  • examples/solid/scroll-restoration/package.json
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to packages/{router-devtools,*-router-devtools}/** : Keep router devtools packages in packages/router-devtools/ and packages/*-router-devtools/

Applied to files:

  • examples/solid/scroll-restoration/package.json
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • examples/solid/scroll-restoration/package.json
  • examples/solid/scroll-restoration/.vscode/settings.json
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.

Applied to files:

  • examples/solid/scroll-restoration/package.json
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to examples/{react,solid}/** : Keep example applications under examples/react/ and examples/solid/

Applied to files:

  • examples/solid/scroll-restoration/package.json
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.

Applied to files:

  • examples/solid/scroll-restoration/.vscode/settings.json
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript in strict mode with extensive type safety across the codebase

Applied to files:

  • examples/solid/scroll-restoration/tsconfig.json
🔇 Additional comments (8)
examples/solid/scroll-restoration/.gitignore (1)

1-5: Standard .gitignore pattern set looks good.

The file includes all the necessary patterns for a Vite-based Node.js project: dependency directories, build outputs (both standard and SSR variants), OS metadata, and local environment files. Nothing appears to be missing.

docs/router/config.json (1)

653-656: LGTM!

The new example entry follows the established pattern and is correctly placed within the Solid framework examples section.

examples/solid/scroll-restoration/README.md (1)

1-6: LGTM!

The README follows the standard format for example projects with clear setup instructions.

examples/solid/scroll-restoration/vite.config.js (1)

1-7: LGTM!

Standard Vite configuration with the Solid plugin properly configured.

examples/solid/scroll-restoration/tsconfig.json (1)

1-12: LGTM!

TypeScript configuration is appropriate for a Solid.js example with strict mode enabled and correct JSX settings.

examples/solid/scroll-restoration/.vscode/settings.json (1)

1-11: LGTM!

The VSCode settings appropriately exclude the autogenerated routeTree.gen.ts file from watchers, search, and mark it as readonly to prevent accidental modifications.

Based on learnings.

examples/solid/scroll-restoration/src/styles.css (1)

1-21: LGTM!

The stylesheet correctly uses Tailwind CSS v4 syntax with the new @import 'tailwindcss' directive, custom base layer styling, and appropriate utility classes for light/dark mode theming.

examples/solid/scroll-restoration/postcss.config.mjs (1)

1-5: LGTM!

PostCSS configuration correctly uses the @tailwindcss/postcss plugin for Tailwind CSS v4 integration.

Comment on lines +13 to +14
"@tanstack/solid-router": "^1.135.2",
"@tanstack/solid-router-devtools": "^1.135.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use workspace protocol for internal dependencies.

The internal TanStack Router packages should use the workspace:* protocol instead of version numbers to ensure they reference the local workspace packages during development.

As per coding guidelines.

Apply this diff:

-    "@tanstack/solid-router": "^1.135.2",
-    "@tanstack/solid-router-devtools": "^1.135.2",
+    "@tanstack/solid-router": "workspace:*",
+    "@tanstack/solid-router-devtools": "workspace:*",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@tanstack/solid-router": "^1.135.2",
"@tanstack/solid-router-devtools": "^1.135.2",
"@tanstack/solid-router": "workspace:*",
"@tanstack/solid-router-devtools": "workspace:*",
🤖 Prompt for AI Agents
In examples/solid/scroll-restoration/package.json around lines 13 to 14, the
internal TanStack Router dependencies currently use fixed version numbers;
change both "@tanstack/solid-router" and "@tanstack/solid-router-devtools" to
use the workspace protocol by replacing their version strings with "workspace:*"
so they resolve to the local workspace packages during development.

})

// Let's use TanStack Virtual to virtualize some content!
let virtualizerParentRef: any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Avoid any type for better type safety.

The any type weakens TypeScript's type checking. Use a more specific type for the virtualizer parent ref.

As per coding guidelines.

Apply this diff:

-  let virtualizerParentRef: any
+  let virtualizerParentRef: HTMLDivElement | undefined
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let virtualizerParentRef: any
let virtualizerParentRef: HTMLDivElement | undefined
🤖 Prompt for AI Agents
In examples/solid/scroll-restoration/src/main.tsx around line 104, the variable
virtualizerParentRef is typed as any which weakens type safety; change its type
to a concrete DOM/ref type such as HTMLDivElement | null (or a Solid ref type
like Ref<HTMLDivElement | null> / (el: HTMLDivElement | null) => void if using
function refs), update any related assignments/uses to match the chosen type,
and add necessary imports or type annotations so TypeScript enforces correct DOM
element handling.

@birkskyum birkskyum merged commit f581aa9 into main Nov 12, 2025
6 checks passed
@birkskyum birkskyum deleted the docs(solid-router)--scroll-restoration-example branch November 12, 2025 18:30
roduyemi pushed a commit to roduyemi/oss-router that referenced this pull request Nov 19, 2025
* docs(solid-router): scroll restoration example

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Everything documentation related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants