Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

content: Expand notes on preloading data #1306

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
atilafassina wants to merge 26 commits into main
base: main
Choose a base branch
Loading
from preload-entries
Open

Conversation

@atilafassina
Copy link
Member

@atilafassina atilafassina commented Oct 18, 2025
edited
Loading

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

Copy link

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

Copy link

netlify bot commented Oct 18, 2025
edited
Loading

Deploy Preview for solid-docs ready!

Name Link
🔨 Latest commit f291d4d
🔍 Latest deploy log https://app.netlify.com/projects/solid-docs/deploys/69041fcd8b8b30000833d8b8
😎 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.

Copy link

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
Copy link

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

@LadyBluenotes LadyBluenotes Oct 20, 2025

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

@atilafassina atilafassina Oct 20, 2025

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

@LadyBluenotes LadyBluenotes Oct 20, 2025

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
Member Author

@atilafassina atilafassina Oct 23, 2025

Choose a reason for hiding this comment

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

if there is some form of an example on the page of what it'd look like to modify it.
There's no way to modify the preload threshold. This is a magical number to prevent eager preloading.

The hover in this case is the regular browser hover, there's nothing framework specific on this. Regular mouse hovering a link will fire a 300ms timeout that will preload data once fulfilled.

Extending on this right here feels to me like documenting browser APIs or framework implementation details.
The reason I added this table here is only to be more transparent about how the framework works under the hood.

Copy link
Contributor

@devagrawal09 devagrawal09 Oct 24, 2025

Choose a reason for hiding this comment

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

I agree with @LadyBluenotes that a more detailed explanation of what happens during SSR belongs in the solid-start docs, but it's definitely worth a callout on this page that during SSR the preload function will run before rendering, so that data fetching can be kicked off earlier.
SolidStart docs already explain this in more detail so we should provide a link here.

Copy link

@mangs mangs left a comment
edited
Loading

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.

atilafassina reacted with heart emoji

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?

Copy link
Contributor

@devagrawal09 devagrawal09 Oct 24, 2025

Choose a reason for hiding this comment

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

Agreed, it should look something like this

const ComponentWithPreload = () => {
 const [showNested, setShowNested] = createSignal(false)
 return (
	<div>
	 <button
 onMouseEnter={() => Nested.preload()}
 onClick={() => setShowNested(true)}
 >Preload Nested Component</button>
 <Show when={showNested()}>
	 <Nested />
 </Show>
	</div>
 )
}

mangs reacted with rocket emoji

## 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?

Copy link
Member Author

@atilafassina atilafassina Oct 23, 2025

Choose a reason for hiding this comment

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

100%
Great catch!
I need to reword this entire paragraph 🤦

Copy link

Choose a reason for hiding this comment

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

Cool, you seem pretty busy, so I can give it a try. Hopefully it's in the ballpark of what you had in mind.

Copy link
Member Author

@atilafassina atilafassina Oct 26, 2025

Choose a reason for hiding this comment

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

haha yeah, I'm juggling some stuff. But I think everyone is :)

I'd be more than happy if you want to take over this PR, more because I like collaborating. So if you feel like it, it's yours :)

Copy link

Choose a reason for hiding this comment

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

I'm honored! I'm super crazy under water this week, so if it's OK for me to pick this up next week, I'm happy to drive this PR to completion.

Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>
atilafassina and others added 2 commits October 23, 2025 09:54
Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>
Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>

## Preloading data in Nested Lazy Components

Top-level lazy components will automatically be preloaded as well as their preload functions.
Copy link
Contributor

@devagrawal09 devagrawal09 Oct 24, 2025

Choose a reason for hiding this comment

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

I don't think there's a concept of "top level lazy components". The only lazy components that are preloaded are route components, which means this section belongs in the router docs.

It's definitely worth calling out that lazy route components are preloaded automatically, but that callout should be further down in this page, and should link to the router docs where its explained in more detail.


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

@devagrawal09 devagrawal09 Oct 24, 2025

Choose a reason for hiding this comment

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

Curious where you got the 300ms from. I can only see a 20ms timeout here

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

Reviewers

@devagrawal09 devagrawal09 devagrawal09 left review comments

@LadyBluenotes LadyBluenotes LadyBluenotes requested changes

Copilot code review Copilot Copilot left review comments

+1 more reviewer

@mangs mangs mangs left review comments

Reviewers whose approvals may not affect merge requirements

Requested changes must be addressed to merge this pull request.

Labels

solid-router Related to Solid Router solidstart Related to SolidStart

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /