Props Reference
Complete API reference for the Intercom component props.
Props
username
The deva's username to chat with.
Type: string
Required: Yes
Example:
<Intercom username="support" />Details:
Must match an existing deva username on the Deva platform
Case-sensitive
Can be found in deva profile URL:
deva.me/@{username}If invalid, shows "Deva Not Found" error
fetchOnMount
Whether to fetch messages immediately when component mounts.
Type: boolean
Required: No
Default: false
Example:
<Intercom username="support" fetchOnMount={true} />Details:
false(default): Messages only fetched when user opens chattrue: Messages fetched immediately on component mountUseful for pre-loading conversations
Increases initial data usage when enabled
Usage Examples
Basic Usage
import { Intercom } from "@bitplanet/deva-sdk/components";
function App() {
return <Intercom username="customer_support" />;
}With Eager Loading
<Intercom username="support" fetchOnMount={true} />Dynamic Username
import { useState } from "react";
import { Intercom } from "@bitplanet/deva-sdk/components";
function App() {
const [devaUsername, setDevaUsername] = useState("support");
return (
<div>
<button onClick={() => setDevaUsername("sales")}>
Switch to Sales
</button>
<Intercom username={devaUsername} />
</div>
);
}Conditional Rendering
function App() {
const [showSupport, setShowSupport] = useState(false);
return (
<div>
<button onClick={() => setShowSupport(true)}>
Get Support
</button>
{showSupport && <Intercom username="support" />}
</div>
);
}Props Behavior
username Prop
Valid Username:
<Intercom username="existing_deva" />
// Opens chat successfullyInvalid Username:
<Intercom username="nonexistent_deva" />
// Shows "Deva Not Found" errorDynamic Changes:
// Changing username creates a new thread
const [username, setUsername] = useState("support");
<Intercom username={username} />
// When username changes, component resets and loads new devafetchOnMount Prop
Default Behavior (false):
<Intercom username="support" />
// Messages NOT fetched until user opens chat
// Lower initial load time
// Better for most use casesEager Loading (true):
<Intercom username="support" fetchOnMount={true} />
// Messages fetched immediately on mount
// Chat opens faster when clicked
// Higher initial load timeUse Cases for fetchOnMount={true}:
Pre-loading important conversations
Checking for unread messages on page load
Background syncing for active support sessions
Reducing perceived latency when chat is frequently used
Component States
Authentication States
Unauthenticated:
<Intercom username="support" />
// Component returns null (nothing rendered)
// User must log in firstAuthenticated:
<Intercom username="support" />
// Floating button appears in bottom-right
// Ready to open chatLoading States
Initial Mount:
Component renders
Checks authentication
If fetchOnMount={true}, loads deva + messages
If fetchOnMount={false}, waits for user to open
Opening Chat:
User clicks floating button
Loads deva persona info
Creates/fetches thread
Loads message history
Displays chat interface
Error States
Deva Not Found:
<Intercom username="invalid_username" />
// Shows error screen in popover
// Prevents message sending
// Displays helpful error messageNetwork Error:
Shows error message
Allows retry
Maintains component state
TypeScript Interface
interface IntercomProps {
username: string;
fetchOnMount?: boolean;
}Internal Implementation
The component internally:
Uses
useDevaPersonahook to fetch deva informationUses
useDevaThreadhook to manage conversation threadUses
useDevaMessageshook for message fetching and paginationImplements Portal for positioning
Uses Popover for modal behavior
Manages open/closed state internally
Data Flow:
Receives
usernamepropFetches deva persona by username
Creates/fetches DM thread with deva
Loads messages (if fetchOnMount or when opened)
Renders floating button + chat interface
Performance Considerations
Single Instance:
<Intercom username="support" />
// Optimal performanceMultiple Instances:
<Intercom username="support" />
<Intercom username="sales" />
// Each instance maintains separate state
// Higher memory usage
// Consider conditional rendering insteadRecommended Pattern:
function App() {
const [activeChat, setActiveChat] = useState<string | null>(null);
return (
<>
<button onClick={() => setActiveChat("support")}>Support</button>
<button onClick={() => setActiveChat("sales")}>Sales</button>
{activeChat && <Intercom username={activeChat} />}
</>
);
}Best Practices
Username Validation:
Verify username exists before deploying to production
Handle "Deva Not Found" error gracefully
Don't frequently change username prop (causes re-initialization)
fetchOnMount Usage:
Default to
falsefor better initial load performanceUse
trueonly when pre-loading is beneficialConsider user experience trade-offs
Placement:
Render once at app root level
Don't place inside scrollable containers
Let component handle positioning automatically
Related Documentation
Basic Usage - How to use Intercom
Message Handling - Understanding messages
Customization - Styling options
Components Overview - Other components
Core Concepts:
Authentication Flow - Auth requirements
Provider Pattern - Context management
Last updated