Get started - Get started with AI Copilots using Liveblocks and React
Liveblocks is a realtime collaboration infrastructure for building performant
collaborative experiences. Follow the following steps to start adding an
advanced AI chat to your React application using the hooks from
@liveblocks/react
and the components
from @liveblocks/react-ui
.
Quickstart
Install Liveblocks
Every package should use the same version.
Set up an authentication route
Create an authentication endpoint at
/api/liveblocks-auth
, passing a unique user ID toprepareSession
. Each user has their own set of private chats, and this allows Liveblocks to identify who is connecting. Add your secret key from the dashboard.Your endpoint at /api/liveblocks-authSet up the Liveblocks client
To connect the user to their chats, you must add
LiveblocksProvider
to a client component in your app.App.tsxAdd the AI chat component
Import default styles
The default components come with default styles, you can import them into the root of your app or directly into a CSS file with
@import
.Next: create a copilot
AI Copilots is set up and working, but it’s using our default AI model and prompt—the next step is to create a custom copilot using your preferred AI provider and configuration.
Create a copilot
What to read next
Congratulations! You’ve set up the foundation to start building an AI copilot experience for your React application.
- Overview of all features and where to start
- @liveblocks/react API reference
- @liveblocks/react-ui API reference
- How to use a fallback AI model