
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@codebaby-avatars/codebaby-react
Advanced tools
A library to run codebaby on React. That's come with hooks and AvatarProvider.
npm install @codebaby-avatars/codebaby-react
Add our provider surrounding your components
"use client";
import { useRef } from 'react';
import { AvatarProvider } from '@codebaby-avatars/codebaby-react';
const App = () => {
const aProviderRef = useRef(null);
return (
<AvatarProvider
id="react-avatar"
// on ref will provide you an events handler instance
// with listener (on, off) and emitter method
ref={aProviderRef}
// You could listen all codebaby events here
// using lowerCamelCase like 'initialized' should be 'onInitialized'
onInitialized={() => {
console.log('onInitialized');
}}
>
{
// Your components and/or page(s) goes here
// all components that will use useCodebabyEvents, should go here
}
</AvatarProvider>
);
};
Replace "react-avatar" with your avatarId from Codebaby portal.
You can use this hook to access the Event handler instace and set or remove event listeners or dispatch a event too.
The Event handler instace is the same on ref for AvatarProvider and in useCodebabyEvents, with
onto set event listener, andoffto unset, and withtriggerto dispatch event
import { useCodebabyEvents } from '@codebaby-avatars/codebaby-react';
const MyComp = () => {
/* ... */
const { trigger } = useCodebabyEvents();
function handleEvent() {
trigger('ask', 'Why is the sky blue?')
};
/* ... */
};
You can use this hook to verify if codebaby was initialized, if the UI was loaded and do something like set a new event listener.
import { useEffect } from 'react';
import { useCodebabyEvents, useIsInitialized } from '@codebaby-avatars/codebaby-react';
const MyComp = () => {
/* ... */
const { on, off } = useCodebabyEvents();
const {isInitialized} = useIsInitialized();
useEffect(() => {
if(isInitialized) {
const onResponse = (e, responseData) => {
// do something
}
on('response', onResponse);
return () => {
off('response', onResponse);
};
}
}, [isInitialized]);
/* ... */
}
import { useEffect } from 'react';
import { useHandleAvatar, useIsInitialized } from '@codebaby-avatars/codebaby-react';
const MyComp = () => {
/* ... */
const { handleMute } = useHandleAvatar();
const { isUILoaded } = useIsInitialized();
useEffect(() => {
if(isUILoaded) {
handleMute(true);
}
}, [isUILoaded]);
/* ... */
}
This hook provides several functionalities to control the avatar more effectively, including:
null if you want to return the avatar to its original element. The second parameter is an options object { returnToPlace: boolean, notResize: boolean }, where returnToPlace defines if the avatar should return to its original position, and notResize prevents the avatar from resizing after being moved.This document lists all the events supported by the Codebaby library. The events are divided into two categories: triggered events that your application can trigger, and listened events that your application can listen for to respond to specific actions or state changes.
These events can be triggered by your application using ref from AvatarProvider or useCodebabyEvents().trigger:
const avatarProviderRef = useRef(null);
function handleDispatch() {
avatarProviderRef.current.trigger('<event_name>', '<event_data>')
}
/* ... */
<AvatarProvider id="react-avatar" ref={avatarProviderRef}>
{/* ... */}
Replace <event_name> with the event name from the list below, and optional <event_data> with any relevant data for that event. List of Triggered Events
Your application can listen for these events and respond to specific actions or state changes. To listen for an event, you can use ref from AvatarProvider, the event on AvatarProvider with 'on' and first letter of event in uppercase or using useCodebabyEvents().on:
/* ... */
<AvatarProvider onUnmute={() => {
// do something
}}>
{/* ... */}
Don't forget, you should use with 'on' and first character on uppercase, like 'camChange' should be 'onCamChange' and in case like 'record-start' should be 'onRecordStart'
List of Listened Events
Remember to replace the event name and data with the appropriate values for your use case.
FAQs
An interface to the Codebaby API using react.
We found that @codebaby-avatars/codebaby-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.