Skip to main content

Stacks.js Overview

Stacks.js is an SDK for building on the Stacks blockchain. It's a collection of various JavaScript libraries allowing developers to interact with the Stacks blockchain or allow their users to.

There are two main ways developers build applications on the Stacks blockchain:

  • 🔒 Without Direct Private Key Access: For example, a web app that allows users to interact with the Stacks blockchain using their Stacks wallet (browser extension or mobile). Read More in the Connect Guide
  • 🔑 With Private Key Access: For example, managing funds with the Stacks.js CLI, building a backend (which can sign transactions directly).

Most users interact via their favorite Stacks wallet. Developers can build web apps, which prompt the user for an action (e.g. sign a transaction), and then the wallet will handle the rest. The wallet will act in the security, and best interest of the user, and the user will be able to review the transaction before signing.

Nevertheless, direct private key access is needed for some use cases. Developers can build simple scripts and tools intended for "offline" use. Users may use the Stacks.js CLI directly to send a transaction. Backends may need to automate signing without direct user interaction. In these cases, developers can use the same libraries used by Stacks wallets for account handling and transaction signing.


There are three main integrations used by Stacks enabled applications:

  • Authentication: Register and sign users in with identities on the Stacks blockchain
  • Transaction signing: Prompt users to sign and broadcast transactions to the Stacks blockchain
  • Data storage: Save and retrieve data for users with Gaia

All three of these integrations can be used together to create powerful new user experiences that rival or exceed those of traditional apps while protecting your users' digital rights.

Connect 🌐

Stacks.js starters offer working templates with Stacks Connect pre-installed for a quick and easy way to get started with building Stacks enabled web apps.

References

Below is a list of all Stacks.js libraries and a few JS libraries and helpers maintained by Hiro:

Connecting Wallets

Stacks Primitives

Native Smart Contract Interaction

Others

  • @stacks/cli Command line interface to interact with auth, storage, and Stacks transactions. Github
  • @stacks/blockchain-api-client Auto-generated REST and websocket API for all endpoints provided by the Stacks Blockchain API. Github
  • @stacks/keychain DEPRECATED: replaced by @stacks/wallet-sdk.

Development

There is a main Stacks.js monorepo containing most of the packages, but a few others often also considered as a part of "Stacks.js".

Are we missing anything? Feel free to open issues in the Github repositories.