Skip to main content
near-kit is designed to work seamlessly in browser environments. The logic for building transactions is identical to the server-side; the only difference is that signing is delegated to the user’s wallet via an Adapter.
New to React? Check out @near-kit/react for ready-to-use hooks that handle loading states, error handling, and integrate with React Query or SWR.

🚀 Live Demo

See near-kit running in a real React application using NEAR Connect.

The Adapter Pattern

You initialize the Near instance with a wallet object instead of a private key.
Once initialized, you use near exactly as you would in a backend script. When you call .send(), the library automatically triggers the wallet’s popup for the user to approve the transaction.

NEAR Connect

NEAR Connect is the standard wallet connection library for the NEAR ecosystem.

Setup

Best Practice: React Context

For a more streamlined React experience with built-in hooks, see the @near-kit/react package which provides NearProvider, useView, useCall, and more.
In a React application, you should create a WalletContext to store the Near instance so it can be accessed by any component. Here is a simplified pattern from the Guestbook Demo: