Frontend API (JavaScript)
Control Bit and wire navigation + identity.
Get a Bit instance
import { createBit, getBit } from 'https://cdn.chatbyte.ai/bit/spark.min.js';
const bit = await createBit('your-agent-id');
const existing = getBit('your-agent-id');Widget controls
bit.open();
bit.close();
bit.toggle();Navigation handling
bit.setNavigationHandler((url) => {
router.push(url);
});Identity methods
bit.identify({ token });
bit.onRequestToken(async () => {
const response = await fetch('/api/bit-token');
const { token } = await response.json();
return token;
});For JWT requirements, see JWT & Identity.
For JWT requirements, see JWT & Identity.