@mysten/sui
Version:
Sui TypeScript API
62 lines (45 loc) • 2.04 kB
Markdown
# Install Sui TypeScript SDK
> Install the @mysten/sui package and configure your project
The Sui TypeScript SDK is available in the
[Sui TS SDK monorepo](https://github.com/MystenLabs/ts-sdks) and NPM.
## Install from NPM
To use the Sui TypeScript SDK in your project, run the following command in your project root:
```sh npm2yarn
npm i @mysten/sui
```
The SDK is published as an ESM only package. Make sure your `package.json` includes
`"type": "module"`:
```json
{
"type": "module"
}
```
If you are using TypeScript, your `tsconfig.json` should use a compatible `moduleResolution` setting
such as `"NodeNext"`, `"Node16"`, or `"Bundler"`. See the
[2.0 migration guide](/sui/migrations/sui-2.0#esm-migration) for more details.
## Experimental tag for use with a local Sui network
Projects developing against one of the on-chain Sui networks (Devnet, Testnet, Mainnet) should use
the base SDK published in the NPM registry (previous section) because the code aligns with the
relevant JSON-RPC. If your developing against a
[local network](https://docs.sui.io/guides/developer/getting-started/local-network) built from the
`main` branch of the Sui monorepo, however, you should use the `experimental`-tagged SDK package as
it contains the latest features (or a local build detailed in the section that follows).
```sh npm2yarn
npm i @mysten/sui@experimental
```
## Install from local build
To build the SDK from the Sui monorepo, you must use [pnpm](https://pnpm.io/). With pnpm installed,
run the following command from the `sui` root directory:
```bash
# Install all dependencies
pnpm install
# Run the build for the TypeScript SDK
pnpm sdk build
```
With the SDK built, you can import the library from your `sui` project. To do so, use a path to the
`ts-sdks/packages/sui` directory that is relative to your project. For example, if you created a
folder `my-sui-project` at the same level as `sui`, use the following to import the locally built
Sui TypeScript package:
```bash
pnpm add ../ts-sdks/packages/sui
```