kit
kit copied to clipboard
Suppress the fetch warning automatically whenever SSR is disabled / hash routing is enabled
Describe the problem
It's a little frustrating whenever my console is flooded with messages similar to this when I am developing a hash routing application.
⚡️ [warn] - Loading http://localhost:8090/api/collections/users/auth-refresh using `window.fetch`. For best results, use the `fetch` that is passed to your `load` function: https://svelte.dev/docs/kit/load#making-fetch-requests
My understanding from the docs (please feel free to correct me) is that sveltekit's fetch would have no purpose or advantage whatsoever whenever hash routing is enabled.
(additionally - I am using a third party library so even if there was a purpose to replace the fetch, there would be no way for me to.)
Describe the proposed solution
A check before the warning to determine if it's even recommended.
Potentially related to https://github.com/sveltejs/kit/issues/13217?
Alternatives considered
It's extremely insignificant and obviously not a priority. I'd submit a PR myself but figured it'd be good practice to write the issue first in case I am missing something.
Using fetch anyway would be my preferred option but not possible in all cases (e.g. third party libraries)
Importance
nice to have
Additional Information
No response
From a quick look through the codebase, it seems an app with SSR and prerendering turned off can still benefit from using SvelteKit's fetch since it tracks the fetched URL (mentioned here). This allows users to invalidate against that URL to re-run load functions fetching that data. Otherwise, it probably would be easy to turn the warning off if hash routing is enabled. Maybe there should be a configuration to turn off this warning? cc: @dummdidumm
yeah, same issue. I am building an spa and some third party lib uses window.fetch and has no option to supply another implementation.
@FantixX I have the same issue. I use PocketBase JS SDK which uses the native fetch API. For these cases, there should definitely be an opporunity to turn this warning off.
In general, there should be a (documented) way to turn off warnings. The person writing the code usually can decide what is best or not in this case. So having the possiblity to tunr off warnings would be very nice! ❤️🔥
@FantixX I have the same issue. I use PocketBase JS SDK which uses the native fetch API. For these cases, there should definitely be an opporunity to turn this warning off.
In general, there should be a (documented) way to turn off warnings. The person writing the code usually can decide what is best or not in this case. So having the possiblity to tunr off warnings would be very nice! ❤️🔥
Absolutely and additionally I find it odd that this isn't a larger issue for more people? There are so many possible situations I could think of where you can't use the Kit fetch() for some reason. A warning is a good idea generally to enforce best practices, but I know what I'm doing and I should have the option to do it in peace.