Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
alpha-ai-avatar-sdk-react
Advanced tools
Hello! 👋 This tutorial will help you get started with the Avatar SDK for React.
To install the package, run the following command:
npm i alpha-ai-avatar-sdk-react
To get started, first import the necessary components from the SDK:
import { AvatarProvider, AvatarClient } from 'alpha-ai-avatar-sdk-react';
Next, initialize AvatarClient
with your configuration. Replace YOUR_API_KEY
with the API key provided by our team:
const client = new AvatarClient({ apiKey: 'YOUR_API_KEY' });
apiKey
(required): Your API key for authentication.baseUrl
(optional): Send 'https://staging.avatar.alpha.school'
to use the staging environment. Defaults to the production URL.Wrap your React app with AvatarProvider
to ensure all components can access the avatar data:
import React from 'react';
import ReactDOM from 'react-dom/client';
import { AvatarProvider, AvatarClient } from 'alpha-ai-avatar-sdk-react';
import App from './App';
const client = new AvatarClient({ apiKey: 'YOUR_API_KEY' });
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<AvatarProvider client={client}>
<App />
</AvatarProvider>,
);
To connect to the avatar, use the connect
method. We recommend only calling this method after the user has interacted with the page. Calling it before may result in issues with audio playback.
const { connect } = useAvatar();
function handleClick() {
connect().then(() => {
console.log('Connected to the avatar!');
});
}
Use the Avatar
component and useAvatar
hook to interact with the avatar:
import { Avatar, useAvatar } from 'alpha-ai-avatar-sdk-react';
function App() {
const { say, stop, switchAvatar } = useAvatar();
return (
<div>
<Avatar style={{ borderRadius: '20px', width: 250, height: 250 }} />
<div style={{ display: 'flex', gap: '10px' }}>
<button type='button' onClick={() => say('Hello, how are you?')}>
Send Message
</button>
<button type='button' onClick={stop}>
Stop Avatar
</button>
<button type='button' onClick={() => switchAvatar(4)}>
Switch Avatar
</button>
</div>
</div>
);
}
export default App;
You can explore our comprehensive list of plugins supported within the Avatar SDK to streamline and accelerate your application development process. For detailed information about each plugin, refer to our plugins documentation.
You can find a few examples in the examples folder of the library. These examples demonstrates how to configure and use the SDK in a React project.
For a detailed overview of all supported configurations, please refer to our comprehensive documentation.
Note: Always ensure you keep your API key secure and do not expose it in publicly accessible code.
Congratulations! You have successfully integrated the Avatar SDK into your React app. 🎉 Feel free to experiment and build more complex components with avatars.
FAQs
Alpha AI Avatar SDK (React)
The npm package alpha-ai-avatar-sdk-react receives a total of 45 weekly downloads. As such, alpha-ai-avatar-sdk-react popularity was classified as not popular.
We found that alpha-ai-avatar-sdk-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.