React

Add the widget to your React project using npm or your favorite JavaScript package manager.

npm install @kimafinance/kima-transaction-widget redux react-redux pino-pretty

You'll need to add the following:

  • The <KimaProvider> component in App.tsx

  • The <KimaTransactionWidget> which interacts with Kima

  • A link to the Kima Transaction Backend (or build your own)

  • A Reown project id

For the purposes of this example, we'll just add the widget to App.tsx, but it can go anywhere it makes sense for your project.

Open App.tsx, wrap your existing components with the <KimaProvider> and add the <KimaTransactionWidget> component.

If you don't have one already, you'll need to get a free Reown project ID from Reown Cloudarrow-up-right and pass it to the projectId prop on <KimaProvider>.

import React from "react";

import {
  KimaTransactionWidget,
  KimaProvider,
  ModeOptions,
  ColorModeOptions,
} from "@kimafinance/kima-transaction-widget";
import "@kimafinance/kima-transaction-widget/index.css";

const App = () => {
  return (
    <KimaProvider
      projectId="your-project-id"
      kimaBackendUrl="http://localhost:4000"
    >
      <KimaTransactionWidget
        theme={{ colorMode: ColorModeOptions.light }}
        mode={ModeOptions.bridge}
      />
    </KimaProvider>
  );
};

export default App;

The widget detects the active environment from your backend /chains/env endpoint, so you do not need to pass a networkOption prop manually.

There are several configuration options, which are described in the Configuration options section.

Polyfills

For new integrations, prefer a modern setup such as Vite or Next.js. Those are the maintained reference examples in the widget repo.

The instructions below are only for older Create React App / Webpack setups that still need Node core module polyfills.

If you are using a later version of webpack (>= 5), you will need to polyfill node core modules using react-app-rewired.

This can be resolved by adding a file at the root of your project named config-overrides.js. Paste the following content into the file:

Example

The easiest way to see the widget working in a maintained setup is to check out the Vite examplearrow-up-right or the Next.js examplearrow-up-right in the widget repo.

Use the polyfill workaround above only if you are integrating into an older CRA/Webpack application that cannot move to Vite or Next.js yet.

Last updated