-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
"onBeforeNavigate" navigation interceptor and "onNavigate" lifecycle function #2982
Conversation
🦋 Changeset detectedLatest commit: eea4279 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@benmccann I've implemented the required changes, this can be reviewed again. |
Note: I've put this into next maintainer's meeting list to discuss the path forward of it. |
❌ Deploy Preview for kit-demo failed. 🔨 Explore the source changes: eea4279 🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/61d177d01fee120008835396 |
Closing this in favor of #3293 |
This pr closes issues #2974 and #560
This pr introduces a
onBeforeNavigate
interceptor and aonNavigate
lifecycle function.onBeforeNavigate
This is a navigation interceptor that can be used to either look up the incoming URL we are going to navigate to or even prevent the navigation from completing by cancelling the navigation request. It works only for internal app navigation.
The navigation interceptor is called
onBeforeNavigate
and is being called each time we use the following methods:The interceptor can be used in the following way:
It can be used with and without async, also It works without a return.
onNavigate
Additionally, the pr adds a
onNavigate
lifecycle function that runs when the page mounts, and also whenever SvelteKit navigates to a new URL but stays on this component.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0