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
svelte-kit: using initClient throws with Error: Function called outside component initialization #1660
Comments
@babichjacob here said we cannot use |
Happy to reopen this if I'm wrong, but this isn't related to urql. Since you're already asking them the question and none of us have really worked on SvelteKit, I'd assume they can help you. They're referring to calling Furthermore, we simply don't support SvelteKit yet but have an RFC on extending our API surface for the load function. However, this isn't a bug issue or report. 😅 if you follow an obviously working code snippet 1:1 and you copy it to a different runner (like Vite to SvelteKit) and it then stops working that's because of something there. I'd assume "layout" is maybe a special component and you can't introduce context there. Probably because it's static-only |
So can we say with certainty that @urql-svelte does NOT work with SvelteKit? |
I'm not using the I'm trying that code not only in |
If I use
Maybe it's a simple issue that you, geniuses, can fix immediately. |
Hey! As noted in the documentation for Svelte bindings you might have issues when using vite: {
optimizeDeps: {
exclude: ['@urql/svelte'],
}
} Normally this would be in a |
Adding optimizeDeps option is not working for me using SvelteKit |
Same, I see that |
Please remove |
@frederikhors just did that same problem. Here's my system info:
Can you paste an example snippet of your code? |
I think I got it working. I was calling the |
urql version & exchanges:
"@urql/svelte": "1.2.2"
Reproduction
https://github.com/frederikhors/issue-urql-svelte-kit
Steps to reproduce
npm run dev
open http://localhost:3000/
Actual behavior
I'm using https://kit.svelte.dev/docs#introduction-getting-started (
npm init svelte@next my-app
) with the code taken from https://github.com/FormidableLabs/urql/tree/main/examples/with-svelte/src but it throws in console with:(the only running code is in https://github.com/frederikhors/issue-urql-svelte-kit/blob/master/src/routes/__layout.svelte)
Why?
The text was updated successfully, but these errors were encountered: