|
1 |
| -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). |
| 1 | +# How to Setup React Query in Next.js 13 App Directory |
2 | 2 |
|
3 |
| -## Getting Started |
| 3 | +Are you interested in using React Query in your Next.js 13 app directory? If so, you've come to the right place! In this article, I'll guide you through the process of setting up React Query and making the QueryClient accessible to all components in the component tree. |
4 | 4 |
|
5 |
| -First, run the development server: |
| 5 | + |
6 | 6 |
|
7 |
| -```bash |
8 |
| -npm run dev |
9 |
| -# or |
10 |
| -yarn dev |
11 |
| -# or |
12 |
| -pnpm dev |
13 |
| -``` |
| 7 | +## Topics Covered |
14 | 8 |
|
15 |
| -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 9 | +- Setup the Next.js 13 Project |
| 10 | +- Create a Custom Query Client Provider |
| 11 | +- Create a Request-scoped Instance of QueryClient |
| 12 | +- Create a Custom Hydrate Component |
| 13 | +- Provide the QueryClient Provider to Next.js |
| 14 | +- Prefetching Data Using Hydration and Dehydration |
| 15 | + - Create the Client-Side Component |
| 16 | + - Create the Page Component |
| 17 | +- Prefetching Data Using Initial Data |
| 18 | + - Create the Client-Side Component |
| 19 | + - Create the Page Component |
| 20 | +- Create Links to the Pages |
| 21 | +- Conclusion |
16 | 22 |
|
17 |
| -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
18 | 23 |
|
19 |
| -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. |
| 24 | +Read the entire article here: [https://codevoweb.com/setup-react-query-in-nextjs-13-app-directory/](https://codevoweb.com/setup-react-query-in-nextjs-13-app-directory/) |
20 | 25 |
|
21 |
| -The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. |
22 |
| - |
23 |
| -This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. |
24 |
| - |
25 |
| -## Learn More |
26 |
| - |
27 |
| -To learn more about Next.js, take a look at the following resources: |
28 |
| - |
29 |
| -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
30 |
| -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
31 |
| - |
32 |
| -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! |
33 |
| - |
34 |
| -## Deploy on Vercel |
35 |
| - |
36 |
| -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. |
37 |
| - |
38 |
| -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
0 commit comments