Build better video and audio apps with Daily's React Components Library
Tags: react, webrtc, sdks
Published: 2023-04-24 16:48:52

_By Daily Engineers Christian Stuff, Jonathan Taylor_

[Daily React](https://docs.daily.co/reference/daily-react?ref=daily.co) is a helper library for handling common patterns when building Daily applications in [React](https://react.dev/?ref=daily.co). Containing hooks, components, and utilities, Daily React helps developers build applications faster with less code. It is built on top of our years of experience developing [Daily Prebuilt](https://www.daily.co/products/prebuilt-video-call-app/?ref=daily.co) and supporting our customers with running calls at scale.

Read on for more on what the library solves for. We also discuss in the conclusion where the the library fits into our developer ecosystem and the different ways engineers can build.

## Why we created Daily React

### Client performance & scale

When discussing client performance with our customers, we often address the challenges of working with real-time media and the frequent updates and rendering required by the UI. Carefully managing state mutations can be a laborious but critical task for ensuring a smooth end-user experience across multiple devices and browsers.

Optimizing a client involves combing through the component hierarchy, monitoring prop changes, memoizing data selectors, and engaging in lots of debugging and testing. This is made even more challenging when apps need to support larger call sizes, where the flow of updates and mutations is more frequent.

Our experience engineering [Daily Prebuilt](https://www.daily.co/products/prebuilt-video-call-app/?ref=daily.co) (our hosted call component, which is a ready-to-use embeddable video chat interface) for massive scale as well as supporting customers across multiple creative use cases has provided us with valuable knowledge on how to overcome these challenges. Daily React is built on this expertise, and we hope it will enable you to spend less time optimizing and more time focusing on your big ideas.

### Sometimes, browsers break things

Browsers each adopt the [WebRTC specification](https://www.w3.org/TR/webrtc/?ref=daily.co) in their own way and have unique requirements for developers. These requirements are continually evolving, so developers must cater to each platform accordingly. What works on Chrome may not necessarily work on Safari, and vice versa.

While Daily can shield developers from specific browser quirks in our SDKs, the way you construct your user interface matters, too. For example, some browsers prefer media elements to be left untouched in the DOM instead of being continually mounted and unmounted, or some handle device permissions in a certain manner.

Daily React has these best practices baked in. As we continue to maintain and imbue our expertise into Daily React, developers can reduce their exposure to common pitfalls or breaking changes that may be introduced. This is great news because these issues can be notoriously tricky to debug. We always welcome questions, feature requests, docs suggestions, and PRs!

### React is data-driven, not event-driven

Our Client SDK for JavaScript is an event-driven library that is suitable for most JavaScript implementations and frameworks. However, React is a far more data-driven framework and is conceptually very different.

We wanted to avoid a scenario where developers have to combine the two design patterns themselves. By doing so, we can not only improve the aesthetics of your code (by having fewer event handlers and manual state mapping), but also improve the ergonomics of building Daily apps on React, in the way you’d expect.

---

## If I’m building on React, should I start using this library?

Yes! We’re making this [library](https://github.com/daily-co/daily-react?ref=daily.co) open source and publicly available, but it originates from years of work building our high-performance Prebuilt product, meaning we’re diligent in testing and committed to maintaining it for the future.

The [library](https://github.com/daily-co/daily-react?ref=daily.co) contains individual hooks and components, so if you already have an existing codebase, you can pick and choose which ones to implement right away.

---

## Getting started; what’s inside?

Daily React is available [on GitHub](https://github.com/daily-co/daily-react?ref=daily.co) and can be installed using a package manager such as npm or yarn:

```
npm install @daily-co/daily-react @daily-co/daily-js recoil
```
Inside, you’ll find a collection of hooks, components, and a DailyProvider context that can be used as a higher-order component to facilitate access to the Daily call object throughout your code.

For a full summary of what’s included, please refer to our [Daily React documentation](https://docs.daily.co/reference/daily-react?ref=daily.co).

### Why do I need Recoil?

[Recoil](https://recoiljs.org/?ref=daily.co), a library developed by the React team at Facebook, is a useful extension to React’s in-built Contexts. Recoil provides additional memoization techniques that are powerful when trying to manage mutations and control your render flow. Since you may already be using Recoil, we’ve included it as a peer dependency so you can use the same version across your app to keep the compiled bundle size low.

### Do the rendered components include any styles?

The components included are un-opinionated and as pure as they can be regarding any client display logic. They include all the best-practices for working with video and audio, but can be styled or extended in any way you wish.

You can read more in our [documentation](https://docs.daily.co/reference/daily-react?ref=daily.co).

---

## How this library fits into Daily’s developer ecosystem

At Daily, one of our goals is to simplify the process of building excellent video and audio apps. This applies to experienced WebRTC engineers as much as solo developers who are just starting their journey.

We will talk more about our ecosystem and plans for future libraries in the coming months. For now, here is where Daily React fits into the broader vision:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6owuq974suhp5ncjeulz.jpg)

Each layer of abstraction facilitates further ease-of-use, starting from the advanced low-level APIs and progressing into a fully embeddable, hosted call interface solution.

[Daily React](https://docs.daily.co/reference/daily-react?ref=daily.co) sits above our Web (JavaScript) SDK, and we use it ourselves to build [Daily Prebuilt](https://www.daily.co/products/prebuilt-video-call-app/?ref=daily.co).

As we learn more about our customers and the frameworks they prefer to build with, we aim to introduce additional libraries that provide developers with similar benefits. Are you working with a specific framework that you would like to see supported? Please visit [peerConnection](https://community.daily.co/?ref=daily.co) and let us know!