JavaScript libraries & wallet connectors
The NEAR JavaScript libraries: near-api-js v7, the typed JSON-RPC client, near-kit, NEAR Connect and Wallet Selector — what each does and when to use it.
Beginner6 min read3-question check
On the JavaScript side there are two separate jobs. A client library talks to RPC: reads state, builds and signs transactions with a key you hold (scripts, bots, backends). A wallet connector lets a browser user sign with their own wallet, so your front end never touches a private key.
The landscape changed in 2025–2026: near-api-js v7 re-absorbed the modular @near-js/* packages into one package, and NEAR now recommends NEAR Connect (from HOT Labs) over Wallet Selector for new dApps.
Client libraries#
| Library | Status | What it’s for | Link |
|---|---|---|---|
| near-api-js (v7) | Official | One package for providers, accounts, keys, signers, transaction building, unit helpers (nearToYocto, teraToGas) and parallel transactions with MultiKeySigner. Its README positions it for backends, CLIs and scripts. | near/near-api-js · TypeDoc |
@near-js/* packages (@near-js/accounts, @near-js/providers, …) | Deprecated | The modular packages used by near-api-js v6. The v7 migration guide calls them deprecated; imports move to near-api-js with mostly unchanged names. | Migration guide |
| @near-js/jsonrpc-client | Official | Low-level, fully typed JSON-RPC client generated from NEAR’s OpenAPI spec, with Zod validation and tree-shakable method functions (block, viewAccount, …). Use when you only need typed reads. | near/near-jsonrpc-client-ts |
| near-kit | Community (listed on docs.near.org) | A fetch-like TypeScript API (near.view, near.call, near.send with "5 NEAR" strings), a built-in Sandbox, and NEAR Connect integration. | r-near/near-kit · docs |
TypeScript
import { Account, JsonRpcProvider, KeyPairString, nearToYocto, teraToGas } from 'near-api-js'
const provider = new JsonRpcProvider({ url: 'https://test.rpc.fastnear.com' })
// read-only: no account or key needed
const messages = await provider.callFunction({
contractId: 'guestbook.near-examples.testnet',
method: 'get_messages',
args: {},
})
// state change: an Account signs with a key you control (backend / script)
const privateKey = process.env.NEAR_PRIVATE_KEY as KeyPairString
const account = new Account('example.testnet', provider, privateKey)
await account.callFunction({
contractId: 'guestbook.near-examples.testnet',
methodName: 'add_message',
args: { text: 'Hello!' },
gas: teraToGas('30'),
deposit: nearToYocto('0.1'),
})Wallet connectors#
| Library | Status | What it’s for | Link |
|---|---|---|---|
NEAR Connect (@hot-labs/near-connect) | Recommended for new dApps | Zero-dependency connector. Each wallet’s integration script runs sandboxed in an iframe and is loaded from a shared manifest, so wallets update without dApp releases. Supports HOT, Meteor, Intear, MyNearWallet, OKX and more, plus WalletConnect. near-connect-hooks adds React hooks. | azbang/near-connect · Wallet Login tutorial |
Wallet Selector (@near-wallet-selector/*) | Supported during transition | The long-standing modal with one npm package per wallet (@near-wallet-selector/meteor-wallet, …/ledger, …/ethereum-wallets, …) and @near-wallet-selector/react-hook. Its README now points new integrations to HOT/NEAR Connect. | near/wallet-selector |
TypeScript
import { NearConnector } from '@hot-labs/near-connect'
const connector = new NearConnector({ network: 'testnet' })
connector.on('wallet:signIn', async (event) => {
const wallet = await connector.wallet()
console.log('signed in as', event.accounts[0].accountId)
// wallet.signAndSendTransaction(...) / wallet.signMessage(...) from here
})
connector.on('wallet:signOut', async () => {
console.log('signed out')
})
await connector.connect() // opens the wallet pickerCheck yourself
3 questions · progress saved in this browser