React Bricks

usePages


Hook to fetch the list of pages.

Argument

The hook function accepts as argument an object with this interface:

{
  type?: string;
  tag?: string;
}
type

Optional string to return only the pages with the specified page type

tag

Optional string to return only the pages with the specified tag

Return value

The hook returns an object with {data, error, isFetching}.

The data object has the following shape

{
    id: string
    type: string
    name: string
    slug: string
    meta: IMeta
    status: PageStatus
    isLocked: boolean
    tags: string[]
}

Usage example

const { data: pages, error, isFetching } = usePages()