/** * djarea/channels * * Real-time WebSocket communication with Django Channels. * Type-safe bidirectional messaging. * * ## Setup * * ```tsx * // layout.tsx * import { ChannelProvider } from 'djarea/channels' * * export default function Layout({ children }) { * return ( * * {children} * * ) * } * ``` * * ## Usage * * ```tsx * // Using generated hooks (recommended) * import { useChatChannel } from '@/api/generated.channels' * * function Chat({ room }) { * const chat = useChatChannel({ room }) * * chat.status // 'connecting' | 'connected' | 'disconnected' * chat.messages // DjangoMessage[] * chat.send({ text: 'Hello' }) // Send ReactMessage * } * ``` * * ```tsx * // Using raw hook (for custom channels) * import { useChannel } from 'djarea/channels' * * function CustomChannel() { * const channel = useChannel< * { room: string }, // Params * { user: string; text: string }, // DjangoMessage * { text: string } // ReactMessage * >('chat', { room: 'general' }) * * // ... * } * ``` */ // Context export { ChannelProvider, useChannelContext, useChannelStatus } from './context' export type { ChannelProviderProps } from './context' // Hooks export { useChannel, useChannelLatest, useRPC, RPCError } from './hooks' export type { UseChannelOptions, RPCClient } from './hooks' // Connection (for advanced use) export { ChannelConnection, getDefaultConnection } from './connection' export type { ChannelConnectionOptions, RPCRequest, RPCResponse, RPCSuccessResponse, RPCErrorResponse, } from './connection' // Types export type { ConnectionStatus, ChannelSubscription, SubscribeOptions, } from './types'