Loading…
Loading…
Custom React hooks generated by @woographql/next for countries and product fetching
@woographql/next generates custom React hooks for common data-fetching patterns. These hooks use the internal apiCall utility to communicate with the Next.js API routes.
| Hook | Purpose | Location |
|---|---|---|
| useCountries | Fetch allowed countries and states for address forms | hooks/useCountries/ |
| useFetchProduct | Fetch a product and optional variation by database ID | hooks/useFetchProduct/ |
Both hooks share these patterns:
apiCall to call Next.js API routes rather than querying GraphQL directly from the browsernext.revalidate options to leverage Next.js fetch cachingapiCallBoth hooks depend on:
@woographql/session-utils - Provides time constants (DAY_IN_SECONDS)@utils/apiCall - Internal fetch wrapper for API route communicationgraphql/generated