Replies: 1 comment
-
I don't understand why hooks.client.js does not work with handleFetch - is there a reason? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A thought came to mind while working on a project, and I thought it's worth sharing:
Since
hooks.server.js
is where all server requests are first intercepted before handed to the targeted resource, I realized that in the the client side, a similar functionality already exists in service worker 'fetch' listener as part of the Web API standard.I understand that not all projects are setup with a service worker in mind. However, if SvelteKit is following the Web Platform and encourages developers to follow the best practices and conform to the web standards via the tools and abstractions it offers, I think the idea to consider
hooks.client.js
handle function to be the actual callback to the fetch event handler of the service worker is worth considering, no?Nice symmetry there, and a very fitting place for such a functionality/purpose; in my humble opinion.
Beta Was this translation helpful? Give feedback.
All reactions