> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanamobile.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Polyfill Guide: Solana web3.js

> This guide will teach you how to set up the Solana web3.js library with the necessary polyfills in a React Native or Expo app.

export const FooterDisclaimer = () => {
  return <p className="not-prose mt-16 text-center text-xs text-gray-500 dark:text-gray-400">
      Code samples on this page are subject to the{" "}
      <a className="underline underline-offset-2" href="https://www.apache.org/licenses/LICENSE-2.0">
        Apache 2.0 license
      </a>
      .
    </p>;
};

## Installation

Add the library to your project:

<CodeGroup>
  ```shell yarn theme={null}
  yarn add @solana/web3.js
  ```

  ```shell npm theme={null}
  npm install @solana/web3.js
  ```
</CodeGroup>

## Polyfills

The following polyfills are needed, **only if you intend to use the `Keypair.generate` function**. Otherwise, this polyfill is not
required to use `@solana/web3.js`.

### Install getRandomValues

Add the `react-native-get-random-values` library to your project.

<CodeGroup>
  ```shell yarn theme={null}
  yarn add react-native-get-random-values
  ```

  ```shell npm theme={null}
  npm install react-native-get-random-values
  ```
</CodeGroup>

Then, import the library in your app's entrypoint file (e.g `index.js`), before the `@solana/web3.js` library is imported.

```js theme={null}
import "react-native-get-random-values";
// ...other imports below
```

<Tip>
  **TIP**

  Alternatively, you can use the `expo-crypto` library to polyfill `crypto.getRandomValues`. View this [sample app](https://github.com/solana-mobile/tutorial-apps/blob/main/AnchorCounterDapp/src/polyfills.ts#L7) for a reference of how to polyfill the `crypto` class.
</Tip>

## Example

<FooterDisclaimer />
