The boilerplate comes with a few hooks that you can use as helpers in your code. They are separated into two categories "wordpress hooks" and "frontend hooks".
They are located inside the wordpress/theme/lib/editor/hooks
folder. They must not be used in the frontend, only in the WordPress area (edit.tsx
file).
useGraphQlApi
: A hook to make GraphQL requests to the WordPress APIuseRestApi
: A hook to make REST requests to the WordPress APIuseAcfField
: A hook to get the value of an ACF (Advanced Custom Fields) fielduseIsPostType
: A hook to get if the post type(s) passed as parameter is/are the same as the current post type(s)useLocale
: A hook to retrieve the current locale in WordPress editor (for Polylang plugin)
They are located inside the frontend/src/hooks
folder and can be used in the frontend area.
useCanonical
: A hook to get the canonical URL of the current pageuseHandleInternalLink
: A hook to handle user-generated links with next/routeruseTranslation
: A hook to get the translation of a string