usePages

Hook to fetch the list of pages.

Signature

const usePages = ({
type,
tag,
}: UsePagesArgs = {}): types.IQueryResult<types.PageFromList[], Error>
interface UsePagesArgs {
type?: string
tag?: string
}
PropertyDefinition
typeOptional string to return only the pages with the specified page type.
tagOptional string to return only the pages with the specified tag.

Return value

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

data contains an array of type PageFromList (a Page object without content):

{
id: string
type: string
name: string
slug: string
meta: IMeta
content: IContentBlock[]
authorId?: string
author: Author
invalidBlocksTypes?: string[]
status: PageStatus
isLocked: boolean
tags: string[]
}

Usage example

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