Hooks
useCraftData
Learn how to use the useCraftData hook.
This hook is a fetch wrapper and used internally for all the useCraftQuery
hooks.
You can use this to fetch data from Craft CMS with custom element types or something else. It handles previewing and authorization for you.
Usage
const apiUrl = `?elementType=navigation&handle=mainNavigation&all=1`
const { data, error, loading } = useCraftData(apiUrl)
Type
export function useCraftData<ResT = any>(queryUrl: string, options?: RequestInit): {
data: ResT | null;
loading: boolean;
error: string | null;
}