diff --git a/package-lock.json b/package-lock.json index 14ac073..e6f1c33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,9 @@ "name": "stardust", "version": "0.0.0", "dependencies": { + "@tanstack/query-sync-storage-persister": "^5.100.9", "@tanstack/react-query": "^5.90.20", + "@tanstack/react-query-persist-client": "^5.100.9", "clsx": "^2.1.1", "lucide-react": "^1.14.0", "motion": "^12.38.0", @@ -1531,6 +1533,33 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@tanstack/query-persist-client-core": { + "version": "5.100.9", + "resolved": "https://registry.npmjs.org/@tanstack/query-persist-client-core/-/query-persist-client-core-5.100.9.tgz", + "integrity": "sha512-sCPZZp3D9sOeqcA4SDxjUIm4wVq8PwHebH4ouFZetwjT4xvGjT/cLBQ4Sst+BFcFuk745pCPkf3T4MFliLHECQ==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.100.9" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/query-sync-storage-persister": { + "version": "5.100.9", + "resolved": "https://registry.npmjs.org/@tanstack/query-sync-storage-persister/-/query-sync-storage-persister-5.100.9.tgz", + "integrity": "sha512-v3cShfFtrxiLwc8b/fjQbUO4wIT//wLT5x4WWl8k/11s2ZyW9qpXE4xFWhiuAHCvKLluF0iI7ZnhT7BAlihwgg==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.100.9", + "@tanstack/query-persist-client-core": "5.100.9" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@tanstack/react-query": { "version": "5.100.9", "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.100.9.tgz", @@ -1547,6 +1576,23 @@ "react": "^18 || ^19" } }, + "node_modules/@tanstack/react-query-persist-client": { + "version": "5.100.9", + "resolved": "https://registry.npmjs.org/@tanstack/react-query-persist-client/-/react-query-persist-client-5.100.9.tgz", + "integrity": "sha512-qO7j+3VUZm4YH4T3dWszDqgvO+5+6NB1kSY+QmF7JD6+IONfeNmGyOzyobjmrX+6CYLPQtQ+sjM9vFYaSOAv6A==", + "license": "MIT", + "dependencies": { + "@tanstack/query-persist-client-core": "5.100.9" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@tanstack/react-query": "^5.100.9", + "react": "^18 || ^19" + } + }, "node_modules/@testing-library/dom": { "version": "10.4.1", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", diff --git a/package.json b/package.json index 3d84323..ddc5b18 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,9 @@ "preview": "vite preview" }, "dependencies": { + "@tanstack/query-sync-storage-persister": "^5.100.9", "@tanstack/react-query": "^5.90.20", + "@tanstack/react-query-persist-client": "^5.100.9", "clsx": "^2.1.1", "lucide-react": "^1.14.0", "motion": "^12.38.0", diff --git a/src/App.tsx b/src/App.tsx index ff304bf..09e9dc4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,19 +1,37 @@ -import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { QueryClient } from '@tanstack/react-query'; +import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'; +import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'; import { languages } from './config/languages'; import { LanguageSection } from './components/LanguageSection'; import { Sparkles } from 'lucide-react'; import { motion } from 'motion/react'; import { GithubMark } from './components/icons/GithubMark'; +const ONE_DAY = 1000 * 60 * 60 * 24; + const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: 1, + gcTime: ONE_DAY, }, }, }); +const safeLocalStorage = (() => { + try { + return window.localStorage; + } catch { + return undefined; + } +})(); + +const persister = createSyncStoragePersister({ + storage: safeLocalStorage, + key: 'stardust-query-cache', +}); + const StarParticle = ({ delay, top, left }: { delay: number; top: string; left: string }) => ( +
{/* Background Nebula Effects */}
@@ -154,7 +175,7 @@ function App() {

- + ); }