feat: setup full Next.js toolchain and core dependencies
- Add runtime deps: react-query, react-hook-form+zod, zustand, ky, openapi-fetch, better-auth, react-markdown, shiki, recharts, next-themes, nuqs, sonner, cmdk, vaul, embla-carousel-react, motion, date-fns, tailwind-merge, clsx, cva - Add dev tooling: vitest, testing-library, playwright, prettier(+tailwind plugin), husky, lint-staged, jsdom - Wire providers (QueryClient, Theme, NuqsAdapter, Tooltip, Sonner) into layout - Add vitest/playwright/prettier configs + lint-staged pre-commit hook - Add lib/query-client + lib/http (ky) helpers and sample unit test - Fix react-hooks/set-state-in-effect lint errors (use-mobile useSyncExternalStore, carousel async init) - Remove committed Next-generated types/ duplicates (regenerated under .next/types)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { isServer, QueryClient } from "@tanstack/react-query";
|
||||
|
||||
function makeQueryClient() {
|
||||
return new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 60 * 1000,
|
||||
gcTime: 5 * 60 * 1000,
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let browserQueryClient: QueryClient | undefined = undefined;
|
||||
|
||||
export function getQueryClient() {
|
||||
if (isServer) {
|
||||
// Server: fresh client per request so caches never leak between users.
|
||||
return makeQueryClient();
|
||||
}
|
||||
// Browser: single shared client so the cache survives route changes.
|
||||
if (!browserQueryClient) {
|
||||
browserQueryClient = makeQueryClient();
|
||||
}
|
||||
return browserQueryClient;
|
||||
}
|
||||
Reference in New Issue
Block a user