ar.io LogoAr.io Documentation

ArDrive Core JS

For AI and LLM users: Access the complete ArDrive Core JS documentation in plain text format at llm.txt for easy consumption by AI agents and language models.

The ArDrive Core JS SDK provides a comprehensive TypeScript library for building applications on ArDrive. It offers type-safe interfaces for drive management, file operations, encryption, and seamless integration with Arweave.

Quick Start

Install the SDK

npm install ardrive-core-js

Initialize with a Wallet

import { readJWKFile, arDriveFactory } from 'ardrive-core-js';

// Load your Arweave wallet
const wallet = readJWKFile('./wallet.json');

// Create an ArDrive instance
const arDrive = arDriveFactory({ wallet });

Create a Drive and Upload Files

import { wrapFileOrFolder } from 'ardrive-core-js';

// Create a new public drive
const { driveId, rootFolderId } = await arDrive.createPublicDrive({
  driveName: 'My-Drive'
});

console.log('Drive created:', driveId.toString());
console.log('Root folder:', rootFolderId.toString());

// Upload a file to the drive
const wrappedFile = wrapFileOrFolder('./my-file.pdf');
const uploadResult = await arDrive.uploadPublicFile({
  parentFolderId: rootFolderId,
  wrappedFile
});

console.log('File uploaded:', uploadResult.fileId.toString());

Install the SDK

npm install ardrive-core-js

Configure Polyfills

Polyfills are required for web environments due to Node.js dependencies used by the SDK.

npm install --save-dev vite-plugin-node-polyfills
// vite.config.js
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';

export default defineConfig({
  plugins: [
    nodePolyfills({
      globals: {
        Buffer: true,
        global: true,
        process: true,
      },
    }),
  ],
});

Configure your bundler (Webpack, Vite, Rollup, etc.) to provide polyfills for crypto, process, and buffer. Refer to your bundler's documentation for polyfill configuration.

Use the SDK

import { arDriveFactory } from 'ardrive-core-js/web';

// Initialize with a JWK wallet object
const arDrive = arDriveFactory({ wallet: jwkWallet });

// Create a public drive
const { driveId, rootFolderId } = await arDrive.createPublicDrive({
  driveName: 'My-Drive'
});

console.log('Drive created:', driveId.toString());

Documentation

Core Features

How is this guide?