Skip to main content

fetchTags

The fetchPages function is useful when you want to retrieve all your tags from outside the React context (where you could use the useTagsPublic hook instead).

In particular, this comes in handy to retrieve all the tags during the build process of a static website.

Signature

const fetchTags = async (
apiKey: string,
page: number = 1,
pageSize: number = 100
): Promise<{
items: string[]
pagination: {
page: number
pageSize: number
totalItems: number
totalPages: number
}
}>
PropertyDefinition
apiKeyApi Key of your React Bricks app (a string).
pagePagination's Page number
pageSizePagination's Page size

Usage example

import { fetchTags } from 'react-bricks/frontend'
import config from '../react-bricks/config'

const paginatedTags = await fetchTags(config.apiKey)