CraftPage
Learn how to use the CraftPage component.
The CraftPage
component renders the mapped React page based on your queried data and the contentMapping.pages
property in your craftInit()
configuration.
You can read more about configuring pages in the configuration docs.
import { CraftPage } from '@query-api/react'
<CraftPage content={content} />
content
: The queried data from Craft CMS. This should be an object containing the section handle and its corresponding data.
Usage
Typically the CraftPage
component is used within a catch-all route in your React application. This allows it to handle all paths and render the appropriate page based on the queried data.
If you are curios how to set this up, you can have a look into the quick start guide.
Error Handling
If you're using a catch-all route, you can add a Error
pages to your contentMapping.pages
mapping.
This ensures that any unmapped or erroneous sections gracefully display an error page, improving user experience and preventing unexpected behavior.
You can read more about error pages in the configuration docs.