There are thousands of paginated items in my table. and thousands of possible filter combinations, I can't actually prefetch them all
I use search params and it changes url only after server request is done, so there is some delay
With slow connection it can take 2+s before user can see any visual response and understand that filters are applied
Is it possible to show loading state immediately and then make all requests etc...
#Is it possible to immediately show suspense fallback when applying filters?
12 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
yeah I think you could use <Suspense /> with different key like this
export default async function Page({
searchParams,
}: {
searchParams: { page: string };
}) {
return (
<Suspense
key={JSON.stringify(searchParams)}
fallback={<div>loading...</div>}
>
<Table searchParams={searchParams} />
</Suspense>
);
}
async function Table({ searchParams }: { searchParams: { page: string } }) {
await new Promise((resolve) => setTimeout(resolve, 3000));
return <div>{searchParams.page}</div>;
}
I use it like this actually
I have these timings with enabled throttling, and I can see skeleton only after 2s
do you use loading.tsx for this route?
Nope, but I use another suspense in layout.js for process names fetching
*tsx
I just tested loading.tsx with searchParams doesn't show immediately
but dynamic params it show immediately
could you send me your example please?
app/tables/[...filter]/page.tsx
app/tables/[...filter]/loading.tsx
loading.tsx should be prefetched in production and show immediately on navigation