Skip to content

Commit

Permalink
Merge pull request #660 from xmtp/rygine/js-docs
Browse files Browse the repository at this point in the history
Update JS SDK README
  • Loading branch information
rygine authored Sep 11, 2024
2 parents 71b4685 + 67d0fbf commit fed1b91
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions packages/js-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,61 @@ pnpm install @xmtp/xmtp-js
yarn add @xmtp/xmtp-js
```

Additional configuration is required in React environments due to the removal of polyfills from Webpack 5.
## Requirements

### Buffer polyfill

A Buffer polyfill is required for browser environments.

See [this solution](https://docs.xmtp.org/dms/troubleshoot#why-is-my-app-failing-with-a-buffer-is-not-found-error) for implementation details.

## Troubleshoot

### Buffer polyfill
### WebAssembly issues

This SDK uses WebAssembly, which may require additional configuration in your environment.

#### Vite

**vite.config.js**

```js
import { defineConfig } from 'vite'

export default defineConfig({
optimizeDeps: {
exclude: ['@xmtp/user-preferences-bindings-wasm'],
},
})
```

If you run into issues with Buffer and polyfills, see this [solution](https://xmtp.org/docs/faq#why-is-my-app-failing-with-a-buffer-is-not-found-error).
#### Next.js

Configuration is dependent on your version of Next.js.

**next.config.mjs**

Next.js < 15

```js
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['@xmtp/user-preferences-bindings-wasm'],
},
}

export default nextConfig
```

Next.js >= 15

```js
const nextConfig = {
serverExternalPackages: ['@xmtp/user-preferences-bindings-wasm'],
}

export default nextConfig
```

### BigInt polyfill

Expand Down

0 comments on commit fed1b91

Please sign in to comment.