Svelte 5 Support #7413
-
I'm wondering what is left to support svelte 5 and if the current approach is good. A lot of Svelte 5 apps are blocked so just trying to get a consensus of where community can help. #6981 |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 57 replies
-
I've been pretty limited for time to look into this. Is anyone else free to take the lead until I get more time? |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
How can I try this?The svelte 5 adapter is currently available on a branch: https://github.com/TanStack/query/tree/svelte-5-adapter Each commit has a package preview - you can install a preview by running What is left to do?Now that svelte 5 is out, it hopefully shouldn't be long before this is released. Please try out the package and report any issues! |
Beta Was this translation helpful? Give feedback.
-
@lachlancollins here is the most minimal version of my repo https://github.com/jakubdonovan/testing-svelte5query
|
Beta Was this translation helpful? Give feedback.
-
To anyone following along, I've introduced a breaking change in #7804 To migrate, you will need to define options as functions, just like solid-query: |
Beta Was this translation helpful? Give feedback.
-
Does it work when in svelte.config if you add compilterOptions: runes: true as below?
```
const config = {
preprocess: vitePreprocess(),
kit: {
……
},
compilerOptions: {
runes: true
}
}
```
This enforces Svelte 5 runes throughout app.
|
Beta Was this translation helpful? Give feedback.
-
Can we please get an updated build and or update on merging into main. |
Beta Was this translation helpful? Give feedback.
-
Has anyone ran into an issue with mutateAsync? I'm using superforms with spa mode and when I await it returns the data correctly but immediately checking the mutate variable says it's pending. If I sleep/await a timeout for 1ms and check again it's correct. Think on:input calls form validation, which calls mutateAsync. |
Beta Was this translation helpful? Give feedback.
-
Any timeline to getting the |
Beta Was this translation helpful? Give feedback.
-
Release to manufacturing / GA |
Beta Was this translation helpful? Give feedback.
-
I have tried the svelte 5 branch on my app and so far I have encountered one issue where a mutation like the one below causes a import { createMutation } from "@tanstack/svelte-query";
import type { QueryClient } from "@tanstack/svelte-query";
const updateItem = async (id: string) => {
const response = await fetch(`/api/items/${id}`);
return response.json();
};
const getItem = async (id: string) => {
const response = await fetch(`/api/items/${id}`);
return response.json();
};
export const changeItem = (client: QueryClient) => {
const mutation = createMutation(() => ({
mutationFn: async ({ id }: { id: string }) => {
const updateResponse = await updateItem(id);
// Fetching another query inside mutationFn causes the `state_unsafe_mutation` error
await client.fetchQuery({
queryKey: ["item", id],
queryFn: () => getItem(id)
});
return updateResponse;
},
}));
return mutation;
}; In development the error does not seem to affect the app's functionality and the query is correctly fetched and the UI updates accordingly. Is this a known limitation? |
Beta Was this translation helpful? Give feedback.
-
I opened #8540. I think it concerns us too. |
Beta Was this translation helpful? Give feedback.
How can I try this?
The svelte 5 adapter is currently available on a branch: https://github.com/TanStack/query/tree/svelte-5-adapter
Each commit has a package preview - you can install a preview by running
pnpm add https://pkg.pr.new/@tanstack/svelte-query@<LATEST COMMIT HASH>
(e.g. https://pkg.pr.new/@tanstack/svelte-query@28f98f9)What is left to do?
Now that svelte 5 is out, it hopefully shouldn't be long before this is released. Please try out the package and report any issues!