Package Manager Installation
Install near-api-ts using your preferred package manager:
Requirements
Node.js Version: The library requires Node.js version 24 or higher when running in Node.js environments.
The library also has a peer dependency on Zod for schema validation:
Zod Version: Requires Zod version 4.3.0 or higher (but less than 5.0.0)
The near-api-ts library is designed to work across multiple JavaScript environments:
Node.js
Full support for Node.js 24+ with ESM modules
Browser
Complete browser support with IndexedDB key storage
TypeScript
First-class TypeScript support with full type definitions
Modern Build Tools
Compatible with Vite, Webpack, and other modern bundlers
Import Paths
The library provides different entry points for different environments:
Universal (Default)
Works in both Node.js and browser environments:
import { createTestnetClient, createMemorySigner } from 'near-api-ts';
Node.js Specific
Includes file-based key service for server environments:
import { createFileKeyService } from 'near-api-ts/node';
Browser Specific
Includes IndexedDB-based key service for browser environments:
import { createIdbKeyService } from 'near-api-ts/browser';
Package Structure
The package exports are configured as follows:
{
"exports": {
".": {
"browser": "./dist/browser/index.js",
"node": "./dist/node/index.js",
"default": "./dist/universal/index.js"
},
"./browser": "./dist/browser/index.js",
"./node": "./dist/node/index.js"
}
}
This ensures that your bundler or runtime automatically selects the correct version based on your environment.
Verify Installation
After installation, verify that the library is working correctly:
import { createTestnetClient } from 'near-api-ts';
const client = createTestnetClient();
console.log('NEAR API client created successfully!');
If this runs without errors, you’re ready to start building with NEAR!
Next Steps