An AI component is a React context provider created with createAI. It wraps the application layout so descendant components can access unified AI state, UI state, and server actions. section 4.2.3
Its architecture connects three application concerns:
- createAI defines the available actions plus initial AI and UI state. section 4.2.3
- getMutableAIState resolves conversation history on the server, while streamUI generates streaming React content. section 4.2.3
- useActions, useUIState, and useAIState let child components invoke actions and read or update shared state. section 4.2.3
Wrap the application layout
Import AI from the actions module and place it around the layout’s shared header, main content, and footer. Every descendant can then use the AI hooks without receiving state or actions through props.
