React Hooks
Learn how to use React hooks to control and customize your Embedded NFT Checkout experience
If you are using our previous version of embedded checkout, please refer to the old events guide
Setup Requirements
The Crossmint hooks must be used within components wrapped by both CrossmintProvider
and CrossmintCheckoutProvider
:
useCrossmintCheckout
The useCrossmintCheckout
hook provides access to the checkout state and allows you to build custom UI experiences.
Return Values
Property | Type | Description |
---|---|---|
order | Order | undefined | The current order object containing all order details |
orderClientSecret | string | undefined | The client secret for the current order |
Order Phases
The order can be in one of the following phases:
quote
- Initial phase where price quotes are being generatedpayment
- Payment is being processeddelivery
- NFTs are being delivered to the recipientcompleted
- Order has been successfully completed
For more information on the order lifecycle, see our Order Lifecycle guide.
Here’s how you can use the order data to track the purchase progress:
For more information on the order object, see our Order Properties section.
Complete Example
Here’s a full example showing how to implement a custom checkout experience:
Best Practices
- Provider Setup: Always ensure components using hooks are wrapped with both required providers
- Error Handling: Handle undefined states when accessing
order
properties - Loading States: Provide appropriate loading UI while the order state is initializing
- Type Safety: Take advantage of TypeScript support for better development experience
Migration from Previous Version
If you’re migrating from the previous version, note these key differences:
- The event system has been replaced with the
useCrossmintCheckout
hook - Order status is now accessed through the hook instead of event listeners
- Custom UI is built using React components instead of event handlers
- Components must be wrapped with required providers
The new hook-based approach provides a more React-friendly experience and better TypeScript support compared to the previous event system.