Skip to content

Commit ead81ee

Browse files
committed
setup queryclient and provider
1 parent 76b810c commit ead81ee

File tree

5 files changed

+188
-6
lines changed

5 files changed

+188
-6
lines changed

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
create-project:
2+
pnpm create next-app nextjs14-react-query
3+
4+
install-dependencies:
5+
pnpm add @tanstack/react-query
6+
pnpm add @tanstack/query-core
7+
pnpm add -D @tanstack/eslint-plugin-query
8+
pnpm add -D @tanstack/react-query-devtools

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@tanstack/query-core": "^5.17.10",
13+
"@tanstack/react-query": "^5.17.10",
14+
"next": "14.0.4",
1215
"react": "^18",
13-
"react-dom": "^18",
14-
"next": "14.0.4"
16+
"react-dom": "^18"
1517
},
1618
"devDependencies": {
17-
"typescript": "^5",
19+
"@tanstack/eslint-plugin-query": "^5.17.7",
20+
"@tanstack/react-query-devtools": "^5.17.10",
1821
"@types/node": "^20",
1922
"@types/react": "^18",
2023
"@types/react-dom": "^18",
2124
"autoprefixer": "^10.0.1",
25+
"eslint": "^8",
26+
"eslint-config-next": "14.0.4",
2227
"postcss": "^8",
2328
"tailwindcss": "^3.3.0",
24-
"eslint": "^8",
25-
"eslint-config-next": "14.0.4"
29+
"typescript": "^5"
2630
}
2731
}

pnpm-lock.yaml

+147-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

providers/ReactQueryProvider.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use client';
2+
3+
import React from 'react';
4+
import { QueryClientProvider } from '@tanstack/react-query';
5+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
6+
import getQueryClient from '@/utils/getQueryClient';
7+
8+
function Providers({ children }: React.PropsWithChildren) {
9+
const client = getQueryClient();
10+
11+
return (
12+
<QueryClientProvider client={client}>
13+
{children}
14+
<ReactQueryDevtools initialIsOpen={false} />
15+
</QueryClientProvider>
16+
);
17+
}
18+
19+
export default Providers;

utils/getQueryClient.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { QueryClient } from '@tanstack/query-core';
2+
import { cache } from 'react';
3+
4+
const getQueryClient = cache(() => new QueryClient());
5+
export default getQueryClient;

0 commit comments

Comments
 (0)