Headless Integration Guide
Learn how to integrate Fanfare using the core SDK without UI components, giving you full control over the experience interface.Overview
The headless integration pattern is ideal when you need complete control over the user interface or are building for platforms where the React SDK isn’t suitable. This guide shows you how to use the@waitify-io/fanfare-sdk-core package directly.
What you’ll learn:
- Using the core SDK without framework bindings
- Building custom UI for queue/draw/auction experiences
- Managing state with the journey state machine
- Implementing real-time updates
Prerequisites
- A Fanfare account with API credentials
- JavaScript/TypeScript project (any framework or vanilla JS)
- Understanding of async/await and event-driven programming
When to Use Headless Integration
Choose headless integration when:- Building a mobile app with React Native or other frameworks
- Using Vue, Svelte, or other non-React frameworks
- Need complete UI customization
- Integrating with game engines or canvas-based UIs
- Building server-side applications (Node.js)
Step 1: Install the Core SDK
Install the framework-agnostic core SDK:Step 2: Initialize the SDK
Initialize the SDK with your credentials:Configuration Options
Step 3: Authenticate
Create a guest session or authenticate with credentials:Step 4: Create an Experience Journey
The journey state machine manages the complete experience flow:Step 5: Handle Journey Stages
Process each stage of the journey:Step 6: Perform Journey Actions
Execute actions based on available options:Check Available Actions
Always check what actions are available before showing UI:Step 7: Direct Distribution Module Access
For more control, access distribution modules directly:Queue Operations
Draw Operations
Auction Operations
Step 8: Subscribe to Events
Listen for SDK-wide events:Step 9: Session Management
Handle session restoration and cleanup:Complete Example
Here’s a complete vanilla JavaScript implementation:Framework Examples
Vue 3 Composable
Svelte Store
Testing
Test your headless integration:Troubleshooting
SDK Not Initializing
- Check credentials are correct
- Verify network connectivity
- Enable debug mode:
debug: true
State Not Updating
- Ensure you’ve subscribed to
journey.state.listen() - Check that journey has been started
- Verify authentication completed
Events Not Firing
- Subscribe before performing actions
- Check event name spelling
- Verify SDK is initialized
What’s Next
- Real-time Updates - Polling and websocket patterns
- Error Handling - Robust error management
- Custom Platform - Full custom integration