Install the packages
Install Daily React together with its two peer dependencies,@daily-co/daily-js and jotai:
@daily-co/daily-js and jotai are peer dependencies, not bundled. Installing them explicitly guarantees that your app and Daily React share a single version of each. This matters if you also use daily-js directly (for example, to create your own call object) or use jotai for your app’s own state, because two copies of either would not see each other’s state.Set up the provider
Everything in Daily React reads from a call object held byDailyProvider. Wrap the part of your tree that needs call state in it. The simplest setup, and the one we recommend for most apps, is to let the provider create and manage the call object: pass your room url (and any other factory options such as token or userName) straight to DailyProvider.
Creating the call object yourself
Pass an existingcallObject instead when you need direct control over the instance, for example to access it before the provider mounts, share it outside the provider tree, or create it conditionally. Create it with useCallObject:
Embedding Daily Prebuilt instead
If you want Daily’s ready-made call UI rather than a custom one, create a Prebuilt iframe withuseCallFrame and hand it to the same provider:
A Prebuilt iframe runs in a separate, secure browsing context. Some data the hooks expect is not available across that boundary, most notably raw audio and video tracks, so media hooks like
useMediaTrack will not return tracks for an iframe instance.Next.js and server-side rendering
Daily React’s hooks depend on browser APIs and React state, so they must run on the client.- In the Next.js App Router, mark any component that imports Daily React hooks or components with
'use client'at the top of the file. - If a hook touches
windowor media devices during render, gate the component so it only mounts in the browser (for example, render it after the component has mounted, or with a dynamic import using{ ssr: false }).
Sharing state with your own Jotai store
If your app already uses Jotai, pass your store to both your<Provider> and to DailyProvider via the jotaiStore prop so Daily React’s atoms live in the same store:
Next steps
Quickstart
Put the provider to work in a full example.
The call object and provider
Lifecycle, joining, and leaving in depth.