Mark code to only run in `load` during an actual navigation
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Is there a possibility mark a piece of code as only runnable when an actual navigation has occurred in a load?
export const load = async function ({ route }) {
/**
* Some other code fetching data that will be shown when entering the page
*/
// This will now run on pre-load since it references route.id, so there's no guarantee that the user visited the page if pre-load was on hover
track('visited page', {
route: route.id // Tracking that a page was visited
})
};
Describe the proposed solution
A way to mark a piece of code as only runnable when the actual navigation has been performed
Alternatives considered
Moving it into the +page.svelte file, but it can quickly clutter up the +page.svelte file if there's a lot of things you just want to run during a navigation.
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the load lifecycle described in the issue, especially how route.id causes code to run during pre-load. Compare that behavior with the proposed +page.svelte alternative and identify the navigation signal or API needed. Done means a documented, agreed way to run selected load-related code only after actual navigation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100