Skip to content

Conversation

atilafassina
Copy link
Member

@atilafassina atilafassina commented Oct 18, 2025

Let's expand on how preload works in Solid-Router within or outside a SolidStart app.

  • Clarify why usePreloadroute exists if that's the default behavior
  • Clarify the advanced usage with deeply nested Lazy components
  • Clarify the mechanics/heuristics of how the Router decides to preload/prefetch components and data
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify
Copy link

netlify bot commented Oct 18, 2025

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit 203df8d
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/68f783876e02db00083b15a7
😎 Deploy Preview https://deploy-preview-1306--solid-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atilafassina atilafassina self-assigned this Oct 18, 2025
@atilafassina atilafassina added solid-router Related to Solid Router solidstart Related to SolidStart labels Oct 18, 2025
@atilafassina atilafassina marked this pull request as ready for review October 18, 2025 16:34
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR expands the documentation on data preloading in Solid Router, explaining how preloading works both within and outside SolidStart applications. It provides clarity on when and why to use manual preloading versus automatic preloading behavior.

  • Added comprehensive documentation on automatic vs manual preloading behaviors
  • Enhanced API documentation for usePreloadRoute with detailed type signatures
  • Clarified preloading mechanics with user actions and timing heuristics

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
use-preload-route.mdx Enhanced with usage examples, type signatures, and parameter documentation
preloading.mdx New comprehensive guide on preloading concepts and advanced usage patterns
data.json Added preloading guide to advanced concepts navigation
routing-and-navigation.mdx Minor formatting improvements to code blocks with titles

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

atilafassina and others added 3 commits October 18, 2025 18:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@atilafassina atilafassina changed the title Preload data content: Expand notes on preloading data Oct 18, 2025
@atilafassina atilafassina requested a review from Copilot October 20, 2025 08:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

kodiakhq bot and others added 2 commits October 20, 2025 08:37
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment on lines +8 to +13
When on a [SolidStart](/solid-start) application, this function can also run on the server during the initial page load to start fetching data before rendering. When in a Single-Page Application (SPA), it will load the route's component and its `preload` function when the user hovers or focuses on a link.

| user action | route behavior |
| ----------- | -------------------------------------- |
| hover | with a 300ms delay to avoid excessive preloading |
| focus | immediately |
Copy link
Member

Choose a reason for hiding this comment

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

I think the SolidStart section might be more appropriate in the reference section as a callout so it doesn't get buried here.

Following that change, I also believe it might be better to show a basic code snippet of what the hover would look like. Doesn't have to be too complex, just enough to get the idea across for how it should look.

Copy link
Member Author

Choose a reason for hiding this comment

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

the code snippet is in the respective API references. This entry is to explain conceptually how preloading works in Solid Router. I added links to the the APIs so things didn't get too repetitive

Not sure what you mean about the hover snippet, that's just the browser API, there's no code from the user to manage or handle that. If they hover or focus the anchor tag, preloading will happen.

Remember: preloading is default behavior. Altering it is an advanced concept for users, most cases we want people to feel it "just works".

Copy link
Member

Choose a reason for hiding this comment

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

I think as it stands for me it feels more like an extension of the ref page vs an exposure to the concept as a whole. What I meant by the hover example was that it might make it feel less like a ref page if there is some form of an example on the page of what it'd look like to modify it.

My explanation wasn't entirely great (I'm sorry about that) but I'll try to give you a bit more of an idea as to what I mean tomorrow (unless @devagrawal09 has any ideas before then).

Copy link

@mangs mangs left a comment

Choose a reason for hiding this comment

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

Nice updates here! After all the really generous time you all spent helping me on Discord, I figured the least I could do was return the favor. Curious of your thoughts.


```ts
Used to lazy load components to allow for code splitting.
Components are not loaded until rendered.
Copy link

Choose a reason for hiding this comment

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

Suggested change
Components are not loaded until rendered.
Components are not loaded until rendered or manually preloaded.
## Preloading data in Nested Lazy Components

Top-level lazy components will automatically be preloaded as well as their preload functions.
Though nested lazy components will not be preloaded automatically because they are not part of the route hierarchy.
Copy link

Choose a reason for hiding this comment

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

Suggested change
Though nested lazy components will not be preloaded automatically because they are not part of the route hierarchy.
However, nested lazy components will not be preloaded automatically because they are not part of the route hierarchy.

Top-level lazy components will automatically be preloaded as well as their preload functions.
Though nested lazy components will not be preloaded automatically because they are not part of the route hierarchy.
To preload such components, you can use the `preload` method exposed on the lazy component
Copy link

Choose a reason for hiding this comment

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

Suggested change
To preload such components, you can use the `preload` method exposed on the lazy component
To preload such components, you can use the `preload` method exposed on the lazy component.

return (
<div>
<button onClick={handlePreload}>Preload Nested Component</button>
Copy link

Choose a reason for hiding this comment

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

By the time the button is visible and before it's able to be clicked, <Nested /> is loaded and rendered already no?


## Preloading and Lazy Loading

When a route has nested lazy components, such components will not be part of the route hierarchy, so they **will not** be preloaded with the route. To preload such components, you can use the [`usePreloadRoute`](/solid-router/reference/primitives/use-preload-route) helper in the parent component to load them when needed.
Copy link

Choose a reason for hiding this comment

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

Given the context of this paragraph, the second sentence here seems misplaced and was the problem we were initially discussing on Discord. usePreloadRoute is for preloading routes directly. (await lazy(string)).preload() is what's necessary to properly preload nested lazy components. Was this maybe an editing mixup?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

solid-router Related to Solid Router solidstart Related to SolidStart

3 participants