npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

alpha-ai-avatar-sdk-react

v0.0.20

Published

Alpha AI Avatar SDK (React)

Downloads

238

Readme

Getting Started

npm version

Hello! 👋 This tutorial will help you get started with the Avatar SDK for React.

Table of Contents

Installation

To install the package, run the following command:

npm i alpha-ai-avatar-sdk-react

Usage

Importing and Initializing

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' });

Available Options

  • 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.

Integrating with React

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>,
);

Connecting to the Avatar

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!');
  });
}

Showing and controlling 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;

Plugins

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.

Examples

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.

Documentation

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.