366 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
186
views
How to check if there's cache data in SWR library?
I’m using the SWR library in my Next.js project to handle data fetching. The project includes a filter feature that allows selecting ticket statuses (e.g., Accepted, Rejected). The issue happens when ...
0
votes
2
answers
112
views
How to properly type Axios with response interceptor + useSWR Fetcher in TypeScript?
I'm building a Next.js app with useSWR, axios, and TypeScript.
I have an Axios instance with a response interceptor that returns response.data:
// api.ts
import axios from "axios";
export ...
0
votes
0
answers
29
views
Safely attaching token to GET request to remote API from client
My stack involves a frontend built in Nextjs and an external REST API backend built in another language. For certain requests to the API, authentication is required, and this is currently implemented ...
0
votes
0
answers
28
views
Problem adding html attribute in SWR Mode
In my nuxt application I set the route '/' to swr. But I need to add a class to the html element according to the 'app-theme' cookies. But I can't do this because it's in SWR mode. Is there any way to ...
0
votes
1
answer
147
views
Trouble with useSWR revalidation and React MSAL token refresh
I'm working on an internal facing React web app that uses React-MSAL for authentication and useSWR for all of our GET requests. I've been working on the authentication flow on and off for a few months,...
2
votes
0
answers
317
views
"Uncaught Exception: Error: Connection terminated unexpectedly" with Next and Vercel Supabase Postgres
I'm currently working in a project that uses Next 15, React 18.3.1 and Vercel's Postgres database (supabase). All the connection to the database is done in Next's api. The connection to the database ...
1
vote
1
answer
578
views
Material UI: DataGrid server-side pagination flickering data when using swr
I want to display server-side paginated data on a Material UI DataGrid with data fetched using swr. I've been working through MUI's introduction example for server side data in DataGrid which is using ...
1
vote
0
answers
78
views
Folder structure in Next.js project, having reusable SWR hooks
I am trying to add SWR to my Next.js project but having trouble figuring out where to put my reusable SWR hooks.
For example, I have this useUser hook I call in multiple components:
export default ...
0
votes
1
answer
54
views
Multiple Data Fetching with useSWR in React Hook Leading to Undefined Data
I'm developing a React component ClinicalViewsSummary that retrieves patient encounter data using the useSWR hook. The child component EncounterValuesTile fetches data with various params it has but ...
2
votes
1
answer
267
views
Why a memory leak occurs when I get the data stored in indexedDB inside the useSWR fetcher
I got the data stored in indexedDB inside the fetcher of useSWR.
Then, the memory usage increased every time auto refresh occurred.
When I got the data stored in indexedDB only once from outside of ...
0
votes
1
answer
220
views
How to show Loading when the key changes in useSWR even if the data for the key already exist in cache?
I am using useSWR hook for data fetching. I want to show Loading, whenever the key changes. I have included the filter state in the key of useSWR, so whenever the state updates, it will call the API.
...
0
votes
1
answer
203
views
How distinguish between initialData and fetched data?
I have the following query:
export const useCurrentUser = () => {
const enabled = !isGuestUser();
return useQuery({
queryKey: ['currentUser'],
queryFn: () => getCurrentUser(),
...
1
vote
0
answers
125
views
How to wrap useSWRMutation and use return data
I'm trying to wrap useSWRMutation and its result in my own hook.
Unfortunately I'm doing something wrong since the data error and isMutating are not getting populated.
This is my current code:
export ...
3
votes
1
answer
536
views
Next.js SWR-like behavior with Streaming SSR & PPR
I am building a data-intensive app at my company. There are multiple pages, including
/experiment - lists all experiments, data updated couple times an hour
/experiment/[id] - metadata on the ...
4
votes
1
answer
2k
views
can I use server actions as SWR fetcher?
I wanted to know if this method is optimal or not. Because I did not find any documentation about it.
example
a server action to get the current user information
actions/whoami.ts
"use server&...