-
Notifications
You must be signed in to change notification settings - Fork 331
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
Conversation
Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.
✅ Deploy Preview for solid-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
8602320 to
4a50173
Compare
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.
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
usePreloadRoutewith 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.
src/routes/solid-router/reference/primitives/use-preload-route.mdx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
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.
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.
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".
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.
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).
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.
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.
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.
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.
@mangs
mangs
left a comment
•
edited
Loading
edited
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.
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.
@mangs
mangs
Oct 23, 2025
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.
By the time the button is visible and before it's able to be clicked, <Nested /> is loaded and rendered already no?
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.
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
mangs
Oct 23, 2025
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.
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?
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.
100%
Great catch!
I need to reword this entire paragraph 🤦
@mangs
mangs
Oct 23, 2025
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.
Cool, you seem pretty busy, so I can give it a try. Hopefully it's in the ballpark of what you had in mind.
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.
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 :)
@mangs
mangs
Oct 27, 2025
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.
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>
Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>
Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>
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.
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.
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.
Curious where you got the 300ms from. I can only see a 20ms timeout here
Co-authored-by: Eric L. Goldstein <3359116+mangs@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Let's expand on how preload works in Solid-Router within or outside a SolidStart app.
usePreloadrouteexists if that's the default behavior