Streaming Props into State
Stream component props into components with a few lines of code and no need for useEffect dependency hell.
When working with AI-generated content in Tambo, you often need to update your component state when new content streams in. The useTamboStreamingProps
hook simplifies this common pattern.
Building on Previous Concepts
This guide combines two key Tambo concepts:
- Streaming - The ability to receive AI-generated content in real-time as it's being created
- Component State - Tambo's state management for tracking component state as context for AI
We recommend you read those first.
When using streaming, props arrive incrementally, and you need an efficient way to update your component state without complex useEffect dependencies. useTamboStreamingProps
solves this exact problem.
Using useTamboStreamingProps
Benefits
- Eliminates repetitive useEffect code
- Automatically detects and applies changes
- Only updates when values actually change
- Works with any state shape
- Type-safe with TypeScript
Without vs With
Before (repetitive pattern):
After (clean and simple):
Don't want to use Tambo's state management? You can use your own!
Works the same, but you don't get the benefits of Tambo's state management.