<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mauro Davoli on Medium]]></title>
        <description><![CDATA[Stories by Mauro Davoli on Medium]]></description>
        <link>https://medium.com/@mauro_3720?source=rss-a1d10065c5f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jtb8TVScEU_K0iFDOsWWgQ.png</url>
            <title>Stories by Mauro Davoli on Medium</title>
            <link>https://medium.com/@mauro_3720?source=rss-a1d10065c5f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:52:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mauro_3720/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Efficiently Caching Translations in React with Zustand and Google Translate API]]></title>
            <link>https://blog.gogrow.dev/efficiently-caching-translations-in-react-with-zustand-and-google-translate-api-eb48aea225fc?source=rss-a1d10065c5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb48aea225fc</guid>
            <category><![CDATA[google-translate]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[i18next]]></category>
            <category><![CDATA[zustand]]></category>
            <category><![CDATA[cache]]></category>
            <dc:creator><![CDATA[Mauro Davoli]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 12:47:54 GMT</pubDate>
            <atom:updated>2024-12-20T12:47:54.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="GoGrow blog post “Efficiently Caching Translations in React with Zustand and Google Translate API”" src="https://cdn-images-1.medium.com/max/1024/1*E-BI2bkGne1AU_kGYUMt1g.png" /></figure><figure><img alt="GoGrow blog post “Efficiently Caching Translations in React with Zustand and Google Translate API”" src="https://cdn-images-1.medium.com/max/1024/1*EC85fpoxgkKRq25sNpPjpA.png" /></figure><h4>Introduction</h4><p>Integrating a translation feature in your React app can enhance accessibility and expand your audience. However, repeatedly fetching translations from APIs like Google Translate can increase latency and costs. We’ll combine React, Zustand, and the Google Translate API to build a performant, cache-enabled translation solution to tackle those issues.</p><p>In this article, you’ll learn how to do the following:</p><ol><li>Set up a Zustand store to cache translations and avoid redundant API calls.</li><li>Use Google Translate API for dynamic translations.</li><li>Implement the solution with React hooks for seamless integration.</li></ol><h4>Why Zustand?</h4><p>Zustand is a lightweight state management library that simplifies state handling in React. Its simplicity and scalability make it ideal for managing and caching translations in memory.</p><h4>Step 1: Creating the Zustand Store</h4><p>Our Zustand store will manage:</p><ul><li>A <strong>cache</strong> for storing translations.</li><li>yoA <strong>registry</strong> to track ongoing API requests and avoid duplicates.</li><li>A method to fetch translations while leveraging the cache.</li></ul><pre>import { create } from &quot;zustand&quot;;<br><br>interface TranslationStore {<br>  translations: Record&lt;string, string&gt;;<br>  ongoingRequests: Record&lt;string, Promise&lt;string&gt;&gt;;<br>  getTranslation: (<br>    text: string,<br>    targetLang: string,<br>    fetchTranslation: (text: string, targetLang: string) =&gt; Promise&lt;string&gt;,<br>  ) =&gt; Promise&lt;string&gt;;<br>}<br><br>export const useTranslationStore = create&lt;TranslationStore&gt;((set, get) =&gt; ({<br>  translations: {},<br>  ongoingRequests: {},<br>  getTranslation: async (text, targetLang, fetchTranslation) =&gt; {<br>    const cacheKey = `${text}_${targetLang}`;<br>    const { translations, ongoingRequests } = get();<br><br>    if (translations[cacheKey]) {<br>      return translations[cacheKey];<br>    }<br><br>    if (await ongoingRequests[cacheKey]) {<br>      return ongoingRequests[cacheKey];<br>    }<br><br>    const requestPromise = fetchTranslation(text, targetLang);<br>    set((state) =&gt; ({<br>      ongoingRequests: { ...state.ongoingRequests, [cacheKey]: requestPromise },<br>    }));<br><br>    try {<br>      const translatedText = await requestPromise;<br><br>      set((state) =&gt; ({<br>        translations: { ...state.translations, [cacheKey]: translatedText },<br>      }));<br><br>      return translatedText;<br>    } finally {<br>      set((state) =&gt; {<br>        const updatedRequests = { ...state.ongoingRequests };<br>        delete updatedRequests[cacheKey];<br>        return { ongoingRequests: updatedRequests };<br>      });<br>    }<br>  },<br>}));<br><br>export default useTranslationStore;</pre><h4>Step 2: Integrating Google Translate API</h4><p>Create a function to interact with the Google Translate API:</p><pre>import { useCallback, useState } from &quot;react&quot;;<br>import axios from &quot;axios&quot;;<br><br>const API_KEY = `${process.env.GOOGLE_TRANSLATION_API_KEY}`!;<br>const API_URL = `${process.env.GOOGLE_TRANSLATION_API_URL}`!;<br><br>const useTranslateText = () =&gt; {<br><br>  const translateText = useCallback(<br>    async (text: string, targetLanguage: string) =&gt; {<br>      try {<br>        const response = await axios.post(`${API_URL}?key=${API_KEY}`, {<br>          q: text,<br>          target: targetLanguage,<br>        });<br>        const translated = response.data.data.translations[0].translatedText;<br><br>        setTranslatedText(translated);<br>        return translated;<br>      } catch (err: any) {<br>        return null;<br>      }<br>    },<br>    [],<br>  );<br><br>  return { translateText };<br>};<br><br>export default useTranslateText;</pre><h4>Step 3: Using the Store in a React Component</h4><p>Now, let’s build a component that uses the store to fetch and display translations:</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import useTranslationStore from &#39;./useTranslationStore&#39;;<br>import { useTranslation } from &quot;react-i18next&quot;;<br><br>const TranslationComponent = ({ text }: { text: string }) =&gt; {<br>  const { i18n } = useTranslation();<br>  const [translatedText, setTranslatedText] = useState(&#39;&#39;);<br> <br>  const { translateText } = useTranslateText();<br>  const getTranslation = useTranslationStore((state) =&gt; state.getTranslation);<br><br>   useEffect(() =&gt; {<br>    const translateActions = async () =&gt; {<br>      if (i18n.language === &quot;en&quot;) return;<br><br>        const result = await getTranslation(<br>          &quot;example text&quot;,<br>          i18n.language,<br>          translateText,<br>        );<br><br>        setTranslatedText(result);<br>      }<br>      <br>    fetchTranslation();<br>  }, [text, getTranslation]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Original: {text}&lt;/h1&gt;<br>      &lt;h2&gt;Translated: {translatedText}&lt;/h2&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default TranslationComponent;</pre><h4>Benefits of this Approach</h4><ol><li><strong>Performance Optimization:</strong> Translations are cached, reducing redundant API calls.</li><li><strong>Scalability:</strong> The approach is flexible and can handle additional languages or features.</li><li><strong>Ease of Maintenance:</strong> Zustand’s simple API makes state management clean and intuitive.</li></ol><h4>Conclusion</h4><p>By integrating Zustand and the Google Translate API, we’ve built a highly efficient and scalable translation system. This solution minimizes API usage, improves user experience, and keeps your codebase organized. Start implementing this in your projects and elevate the global reach of your applications! 🚀</p><p>Author: <a href="https://medium.com/@mauro_3720">Mauro Davoli</a></p><figure><img alt="Mauro Davoli, Software Engineer at GoGrow" src="https://cdn-images-1.medium.com/max/1024/0*8yzlG1QV1qPbYFdt.jpeg" /></figure><p>Get notified about <a href="https://www.gogrow.dev/">GoGrow’s</a> open positions by applying here <a href="https://www.gogrow.dev/careers">https://www.gogrow.dev/careers</a> 👩‍💻📣</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb48aea225fc" width="1" height="1" alt=""><hr><p><a href="https://blog.gogrow.dev/efficiently-caching-translations-in-react-with-zustand-and-google-translate-api-eb48aea225fc">Efficiently Caching Translations in React with Zustand and Google Translate API</a> was originally published in <a href="https://blog.gogrow.dev/">GoGrow</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js 14: The Power of URL in State Management]]></title>
            <link>https://blog.gogrow.dev/next-js-14-the-power-of-url-in-state-management-7d38a4e34ca8?source=rss-a1d10065c5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d38a4e34ca8</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[url]]></category>
            <dc:creator><![CDATA[Mauro Davoli]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 23:21:10 GMT</pubDate>
            <atom:updated>2023-11-25T00:29:10.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Olx456Bx1z510RfHR2vdPQ.jpeg" /></figure><figure><img alt="NEXT.JS 14" src="https://cdn-images-1.medium.com/max/680/1*wrzPna2g3zLS4PC0f37Hug.png" /></figure><p>In the ever-evolving landscape of web development, a silent hero has emerged —<strong> the URL</strong>. As frontenders navigate the challenges of integrating a state manager into server components, the URL, provides a welcome solution in Next.js development.</p><p>Beyond its traditional role as a web address, the URL has transformed into a powerful state management tool, revolutionizing how users interact with and save their online experiences.</p><p>This method shows how the URL can do a bunch of things, giving power to both users and developers to:</p><ul><li>share their curated content with a simple link.</li><li>bookmark pages for future reference</li><li>seamlessly save search results</li></ul><h4><strong>Let’s apply this concept with a practical example in a server component.</strong></h4><pre>import Link from &#39;next/link&#39;;<br><br>export default function ProductPage({<br>  searchParams,<br>}: {<br>  searchParams: { [key: string]: string | string[] | undefined };<br>}) {<br>  const selectedColor = (searchParams?.color || &#39;blue&#39;) as string;<br>  const selectedSize = (searchParams?.size || &#39;M&#39;) as string;<br><br>  const sizeVariants = [&#39;S&#39;, &#39;M&#39;, &#39;L&#39;, &#39;XL&#39;];<br><br>  return (<br>    // ...<br>    &lt;div&gt;<br>      {sizeVariants.map((size, index) =&gt; (<br>        &lt;Link<br>          key={index}<br>          href={`?${new URLSearchParams({<br>            color: selectedColor,<br>            size,<br>          })}`}<br>          className={`${<br>            selectedSize === size ? &#39;bg-blue-500&#39; : &#39;bg-gray-200&#39;<br>          } mr-2 inline-block h-8 w-8 text-center leading-8`}<br>        &gt;<br>          {size}<br>        &lt;/Link&gt;<br>      ))}<br>    &lt;/div&gt;<br>    // ...<br>  );<br>}</pre><p>This component accepts a prop named searchParams, which is an object containing key-value pairs representing the parameters from the URL query string. The selectedColor and selectedSize variables are extracted from these parameters.</p><p>Suppose you have a product page for a pink shirt in size ‘XL’. The URL might look like this:</p><pre>https://www.examplestore.com/product-page?color=pink&amp;size=XL</pre><p>Now, let’s break down how the code contributes to this:</p><p><strong>1 — Default Values:</strong></p><p>In essence, default values act as a safety net, ensuring that the component gracefully handles diverse scenarios and remains robust in the face of potential irregularities in the data it receives.</p><pre>const selectedColor = (searchParams?.color || &#39;blue&#39;) as string;<br>const selectedSize = (searchParams?.size || &#39;M&#39;) as string;</pre><p><strong>2 — Link Generation:</strong></p><p>This line constructs the href attribute for each link, creating a new URLSearchParams object with the selected color and the specific size.</p><p>By incorporating new URLSearchParams, developers can create URLs that adhere to standards, ensuring compatibility across different browsers</p><pre>href={`?${new URLSearchParams({ color: selectedColor, size })}`}</pre><p><strong>3 — Styling:</strong></p><p>The class names dynamically style the links, highlighting the selected size with a blue background and providing a visual cue.</p><pre>className={`${<br>  selectedSize === size ? &#39;bg-blue-500&#39; : &#39;bg-gray-200&#39;<br>} mr-2 inline-block h-8 w-8 text-center leading-8`}</pre><h4><strong>Let’s explore an example on the client side featuring a search input.</strong></h4><pre>&#39;use client&#39;;<br><br>import { MagnifyingGlassIcon } from &#39;@heroicons/react/24/outline&#39;;<br>import { useSearchParams, usePathname, useRouter } from &#39;next/navigation&#39;;<br> <br>export default function Search() {<br>  const searchParams = useSearchParams();<br>  const pathname = usePathname();<br>  const { replace } = useRouter();<br> <br>  function handleSearch(term: string) {<br>    const params = new URLSearchParams(searchParams);<br>    if (term) {<br>      params.set(&#39;query&#39;, term);<br>    } else {<br>      params.delete(&#39;query&#39;);<br>    }<br>    replace(`${pathname}?${params.toString()}`);<br>  }<br>}<br><br><br>return (<br>    &lt;div className=&quot;relative flex flex-1 flex-shrink-0&quot;&gt;<br>      &lt;label htmlFor=&quot;search&quot; className=&quot;sr-only&quot;&gt;<br>        Search<br>      &lt;/label&gt;<br>      &lt;input<br>        className=&quot;peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500&quot;<br>        placeholder={placeholder}<br>        defaultValue={searchParams.get(&#39;query&#39;)?.toString()}<br>        onChange={(e) =&gt; {<br>          handleSearch(e.target.value);<br>        }}<br>      /&gt;<br>      &lt;MagnifyingGlassIcon className=&quot;absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900&quot; /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>These lines use Next.js 14 client-side navigation hooks. useSearchParams retrieves the current URL parameters, usePathname gets the current pathname, and useRouter provides routing functionalities. Even if you are in client-side and can use hooks like useState, we continue in the same line of the benefits that using URL as a state manager provides.</p><p><strong>1 —handleSearch:</strong></p><p>The handleSearch function updates the URL parameters based on the provided search term. It utilizes a URLSearchParams object to manage the parameters, setting or deleting the &#39;query&#39; parameter based on whether a term is provided. Finally, it uses replace to update the URL.</p><pre>function handleSearch(term: string) {<br>    const params = new URLSearchParams(searchParams);<br>    if (term) {<br>      params.set(&#39;query&#39;, term);<br>    } else {<br>      params.delete(&#39;query&#39;);<br>    }<br>    replace(`${pathname}?${params.toString()}`);<br>  }</pre><p><strong>2 — defaultValue:</strong></p><p>searchParams.get(&#39;query&#39;)?.toString() retrieves the value of the &#39;query&#39; parameter from the URL. If the parameter exists, it returns the value; otherwise, it returns null.</p><pre>&lt;input<br>        className=&quot;peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500&quot;<br>        placeholder={placeholder}<br>        defaultValue={searchParams.get(&#39;query&#39;)?.toString()}<br>        onChange={(e) =&gt; {<br>          handleSearch(e.target.value);<br>        }}<br>      /&gt;</pre><h4><strong>Sharing Curated Experiences with Ease:</strong></h4><p>One of the most compelling aspects of using the URL as a state manager is the seamless ability to share curated experiences effortlessly. Imagine a user exploring an online store’s vibrant collection of XL-sized, pink-hued products. With the URL serving as the state manager, the experience becomes dynamic and easily shareable.</p><p>Take, for instance, the URL: https://www.examplestore.com/product-page?color=pink&amp;size=XL. This link encapsulates a specific state within the application – in this case, showcasing products tailored to the user&#39;s preference for pink color and XL size. The magic happens when this link is shared.</p><p>Here’s a list of examples showcasing how the URL can serve as an ideal state manager, particularly in the context of server components:</p><p>Pagination: /products?page=2</p><p>Search Inputs: /search?query=shoes&amp;type=sneaker</p><p>Sorting Options: /products?category=clothing&amp;sort=price-asc</p><p>Filtering by Category: /products?category=electronics</p><p>User Preferences: /profile?theme=dark&amp;language=en</p><p>Dynamic Forms: /form?step=2</p><h4><strong>Conclusion</strong></h4><p>The examples showcased here represent just the tip of the iceberg when it comes to leveraging the URL as a powerful state manager in Next.js 14 server and client components. The beauty lies in the simplicity and flexibility of this approach, offering developers a canvas on which they can unleash their creativity.</p><p>Author: <a href="https://medium.com/@mauro_3720">Mauro Davoli</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGK4GI9x8x8pOhFOWDB9jQ.jpeg" /></figure><p>Get notified about <a href="https://www.gogrow.dev/">GoGrow’s</a> open positions by applying here <a href="https://www.gogrow.dev/careers">https://www.gogrow.dev/careers</a> 👩‍💻📣</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d38a4e34ca8" width="1" height="1" alt=""><hr><p><a href="https://blog.gogrow.dev/next-js-14-the-power-of-url-in-state-management-7d38a4e34ca8">Next.js 14: The Power of URL in State Management</a> was originally published in <a href="https://blog.gogrow.dev/">GoGrow</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up React Query in Your Next.js 13 App]]></title>
            <link>https://blog.gogrow.dev/setting-up-react-query-in-your-next-js-13-app-e8edea0d20cc?source=rss-a1d10065c5f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8edea0d20cc</guid>
            <category><![CDATA[data-fetching]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[caching-data]]></category>
            <category><![CDATA[react-query]]></category>
            <dc:creator><![CDATA[Mauro Davoli]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 20:22:58 GMT</pubDate>
            <atom:updated>2023-06-06T16:55:12.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vk56qeDJCA-YcOj0lfBNjw.jpeg" /></figure><figure><img alt="Next.JS" src="https://cdn-images-1.medium.com/max/1024/1*0XtmqDJrkB-_AfwKyYVfDQ.png" /></figure><p>Looking to enhance your Next.js 13 app with the power of React Query? This article will walk you through the process of seamlessly integrating React Query into your project and ensuring that the QueryClient is readily available to all components within your component tree.</p><p>Let’s dive into it.</p><p><strong>Step 1:</strong></p><p>By default, Next.js 13 renders all components on the server. However, React Query does not work with server-side rendering out of the box. To overcome this limitation, we need to create a custom provider that renders the QueryClientProvider within a Client Component.</p><blockquote>src/app/providers.tsx</blockquote><pre>&quot;use client&quot;;<br><br>import { QueryClient, QueryClientProvider } from &quot;@tanstack/react-query&quot;;<br>import { ReactQueryDevtools } from &quot;@tanstack/react-query-devtools&quot;;<br>import { useState } from &quot;react&quot;;<br><br>export default function Providers({ children }: { children: React.ReactNode }) {<br>  const [client] = useState(new QueryClient());<br><br>  return (<br>        &lt;QueryClientProvider client={client}&gt;<br>          {children}<br>          &lt;ReactQueryDevtools initialIsOpen={false} /&gt;<br>        &lt;/QueryClientProvider&gt;<br>  );<br>}</pre><p>Now, let’s incorporate the Provider component into the layout.tsx file.</p><blockquote>src/app/layout.tsx</blockquote><pre>import Providers from &quot;./providers&quot;;<br><br>export default function RootLayout({<br>  children,<br>}: {<br>  children: React.ReactNode;<br>}) {<br>  return (<br>    &lt;html lang=&quot;en&quot;&gt;<br>      &lt;body&gt;<br>        &lt;Providers&gt;{children}&lt;/Providers&gt;<br>      &lt;/body&gt;<br>    &lt;/html&gt;<br>  );<br>}</pre><p><strong>Step 2:</strong></p><p>To guarantee that data remains isolated between users and requests, while still maintaining a single QueryClient instance per request, we can create a request-scoped singleton instance of QueryClient.</p><p>Doing so makes prefetched queries accessible to all components throughout the component tree. This approach also enables us to fetch data within multiple Server Components and utilize &lt;Hydrate&gt; in numerous locations.</p><blockquote>src/lib/get-query-client.ts</blockquote><pre>import { QueryClient } from &quot;@tanstack/query-core&quot;;<br>import { cache } from &quot;react&quot;;<br><br>const getQueryClient = cache(() =&gt; new QueryClient());<br>export default getQueryClient;</pre><p>And now let’s create a custom hydrate component</p><blockquote>src/components/hydrate-client.ts</blockquote><pre>&quot;use client&quot;;<br><br>import { Hydrate as RQHydrate, HydrateProps } from &quot;@tanstack/react-query&quot;;<br><br>function Hydrate(props: HydrateProps) {<br>  return &lt;RQHydrate {...props} /&gt;;<br>}<br><br>export default Hydrate;</pre><p><strong>Step 3:</strong></p><p>Now that we have React Query set up in our Next.js 13 project, let’s dive into its incredible capabilities. We’ll explore how React Query enables server-side data fetching, state hydration, cache dehydration, and seamless rehydration on the client-side.</p><p>With React Query, you can unlock a new level of data management efficiency and responsiveness. Let’s explore these functionalities with a real example.</p><blockquote>src/app/profile/page.ts</blockquote><pre>import { ReactQueryHydrate } from &quot;@/components/react-query-hydrate&quot;;<br>import { client } from &quot;@/lib/api&quot;;<br>import getQueryClient from &quot;@/lib/get-query-client&quot;;<br>import { dehydrate } from &quot;@tanstack/react-query&quot;;<br>import SomeComponent from &quot;@/components/some-component&quot;;<br><br>async function getUser() {<br>  const res = await fetch(&quot;/user&quot;);<br>  const users = (await res.json());<br>  return users;<br>}<br><br>export default async function Profile() {<br>  const queryClient = getQueryClient();<br>  await queryClient.prefetchQuery([&quot;user&quot;], GetUser);<br>  const dehydratedState = dehydrate(queryClient);<br><br>  return (<br>    &lt;ReactQueryHydrate state={dehydratedState}&gt;<br>      &lt;div&gt;<br>        &lt;SomeComponent /&gt;<br>      &lt;/div&gt;<br>    &lt;/ReactQueryHydrate&gt;<br>  );<br>}</pre><blockquote>src/app/components/some-component.tsx</blockquote><pre>&quot;use client&quot;;<br><br>import { useQuery } from &quot;@tanstack/react-query&quot;;<br><br>async function getUser() {<br>  const res = await fetch(&quot;/user&quot;);<br>  const users = (await res.json());<br>  return users;<br>}<br><br>export default function SomeComponent() {<br><br>  const { data, isLoading, isFetching, error } = useQuery({<br>    queryKey: [&quot;user&quot;],<br>    queryFn: GetUser,<br>  });<br><br>  return (<br>    &lt;h1 className=&quot;font-bold&quot;&gt;{data?.full_name}&lt;/h1&gt;<br>  );<br>}</pre><p>Our devtools:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TX412lmZZWPGI5uQCxGxHQ.png" /></figure><p><strong>Conclusion:</strong></p><p>With React Query, you can focus on building intuitive user interfaces and delivering dynamic content without worrying about the complexities of data fetching and state management. It’s a valuable tool that streamlines your development process and helps you create exceptional web applications.</p><p>So, embrace the power of React Query and unlock the full potential of your Next.js 13 project. Happy coding!</p><p>Author: <a href="https://medium.com/@mauro_3720">Mauro Davoli</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGK4GI9x8x8pOhFOWDB9jQ.jpeg" /></figure><p>Get notified about <a href="https://www.gogrow.dev/">GoGrow’s</a> open positions by applying here <a href="https://bit.ly/3ZJ0ihV">https://bit.ly/3ZJ0ihV</a>👩‍💻📣</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8edea0d20cc" width="1" height="1" alt=""><hr><p><a href="https://blog.gogrow.dev/setting-up-react-query-in-your-next-js-13-app-e8edea0d20cc">Setting Up React Query in Your Next.js 13 App</a> was originally published in <a href="https://blog.gogrow.dev/">GoGrow</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>