feat: move configuration localStorage to server side

This commit is contained in:
d-kimsuon
2025-09-01 19:24:08 +09:00
parent 7c96a6316c
commit a07b0468db
19 changed files with 458 additions and 301 deletions

View File

@@ -1,12 +1,39 @@
"use client";
import { QueryClientProvider } from "@tanstack/react-query";
import {
isServer,
QueryClient,
QueryClientProvider,
} from "@tanstack/react-query";
import type { FC, PropsWithChildren } from "react";
import { queryClient } from "./queryClient";
let browserQueryClient: QueryClient | undefined;
export const getQueryClient = () => {
if (isServer) {
return makeQueryClient();
} else {
browserQueryClient ??= makeQueryClient();
return browserQueryClient;
}
};
export const makeQueryClient = () =>
new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: true,
refetchInterval: 1000 * 60 * 5,
retry: false,
},
},
});
export const QueryClientProviderWrapper: FC<PropsWithChildren> = ({
children,
}) => {
const queryClient = getQueryClient();
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);