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: 24 comments 136 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.
This comment has been hidden.
This comment has been hidden.
-
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.
This comment was marked as spam.
This comment was marked as spam.
-
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.
-
The https://github.com/TanStack/query/tree/svelte-5-adapter branch seems to be falling behind |
Beta Was this translation helpful? Give feedback.
-
Should it be relying on The proxying that Svelte does also makes it harder for query data manipulation, the values that you get from |
Beta Was this translation helpful? Give feedback.
-
I hope we will get the working adapter soon, rn we have some issues with Svelte 4 version in our Svelte 5 project :c |
Beta Was this translation helpful? Give feedback.
-
I am wondering if an issue I am dealing with is a problem with my code or the package: Let's say I have the following code in the let query = useGetAllProducts();
if (query.isLoading) {
console.log("loading");
}
if (query.isError) {
console.log(query.error);
}
let searchQuery = $state("");
let filteredProducts: Product[] = $state([]);
$effect(() => {
if (query.data) {
filteredProducts = query.data.filter((product) => product.name.includes(searchQuery));
}
}); The code above works fine, when the data is available, it will render everything properly on the screen however if I try to destructure, like below: let { data: products, isLoading, isError, error } = useGetAllProducts();
if (isLoading) {
console.log("loading");
}
if (isError) {
console.log(error);
}
let searchQuery = $state("");
let filteredProducts: Product[] = $state([]);
$effect(() => {
if (products) {
filteredProducts = products.filter((product) => product.name.includes(searchQuery));
}
}); The code stops working. By "stop working" I mean: it fetches the data (as I can see the JSON retrieved from the external API in the console), but it does not render the information on the screen, as if the package is uncapable of identifying that the data is now available. Let me know if you need the full code. Edit note: Here is the implementation of import { ProductSchema } from "$lib/schemas/Products";
import { BASE_URL } from "$lib/utils/consts";
import { createQuery } from "@tanstack/svelte-query";
import { z } from "zod";
const GetAllProductsResponseSchema = z.array(ProductSchema);
export type GetAllProductsResponse = z.infer<typeof GetAllProductsResponseSchema>;
async function getAllProducts() {
const response = await fetch(`${BASE_URL}/products/`, {
headers: {
"Content-Type": "application/json"
});
const body = await response.json();
return GetAllProductsResponseSchema.parse(body.products);
}
export function useGetAllProducts() {
return createQuery(() => ({
queryKey: ["products"],
queryFn: async () => await getAllProducts()
}));
} |
Beta Was this translation helpful? Give feedback.
-
I'm trying the svelte-5-adapter branch for the first time and using Svelte Kit I'm getting:
Steps:
Why is that? |
Beta Was this translation helpful? Give feedback.
-
So, hmm, how does someone use Tanstack query with Svelte 5 ? I tried the special branch, but it still doesn't seem to work for some reason (that, or I missed a step? 🤔 ) |
Beta Was this translation helpful? Give feedback.
-
Svelte 6 is on its way, and if Tanstack Query remain runes incompatible, Svelte user will have to start switching away. It is around 18 months since Svelte 5 preview and 9+ months since Svelte 5 launch. I am now removing Tanstack Query from my tech stack. |
Beta Was this translation helpful? Give feedback.
-
Been following this closely and I was using the unmerged PR successfully. But have removed it now because Svelte remote functions are awesome! There are parts of it not well documented yet that have (at least for me) made the need for Svelte-Query redundant. Putting it out there in case it helps anyone. |
Beta Was this translation helpful? Give feedback.
-
Been running the svelte 5 branch for a while and it is working great. |
Beta Was this translation helpful? Give feedback.
-
I'm using the svelte 5 branch which is working well for me. I don't really know why this hasn't been merged. It would be great for Svelte to get more love - having come from React, Svelte is superb and is now my framework of choice. |
Beta Was this translation helpful? Give feedback.
-
Your best hope is to get tanners attention on all platforms.Otherwise this will be sitting here for a very long time. Sent from my iPhoneOn Sep 19, 2025, at 4:55 AM, Saul ***@***.***> wrote:
I'm using the svelte 5 branch which is working well for me. I don't really know why this hasn't been merged. It would be great for Svelte to get more love - having come from React, Svelte is superb and is now my framework of choice.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone following along here, as of #9502, the query repo uses changesets, and we are able to version packages independently. This means that individual adapters will be able to update without needing to wait for all the other packages (primarily core) to have substantial breaking changes too. This means that the runes adapter is coming soon! This will be released as svelte-query v6. I would appreciate it if you could test out this final preview: #9694 Direct install command: |
Beta Was this translation helpful? Give feedback.
Hi everyone following along here, as of #9502, the query repo uses changesets, and we are able to version packages independently. This means that individual adapters will be able to update without needing to wait for all the other packages (primarily core) to have substantial breaking changes too.
This means that the runes adapter is coming soon! This will be released as svelte-query v6. I would appreciate it if you could test out this final preview: #9694
Direct install command:
pnpm add https://pkg.pr.new/@tanstack/svelte-query@9694