Near Learn

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#

LibraryStatusWhat it’s forLink
near-api-js (v7)OfficialOne 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, …)DeprecatedThe 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-clientOfficialLow-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-kitCommunity (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
near-api-js v7: a view call through the provider, a change call through an Account
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#

LibraryStatusWhat it’s forLink
NEAR Connect (@hot-labs/near-connect)Recommended for new dAppsZero-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 transitionThe 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
NEAR Connect: sign the user in from the browser
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 picker

Check yourself

3 questions · progress saved in this browser

  1. 1.You are starting a new React dApp where users sign transactions with their own wallets. What do you integrate?
  2. 2.A nightly Node.js job must call distribute_rewards on your contract using a key stored in your secrets manager. Which library?
  3. 3.An old codebase imports JsonRpcProvider from @near-js/providers. What is the current recommendation?