Setup
Install library
The Checkout SDK features are only available when the library is installed via a Package Manager such as npm
or yarn
.
Prerequisites
Node Version 20 or later
Immutable's Typescript SDK requires **Node v20** (Active LTS version) or **higher**. Node v20 can be installed via `nvm`.
To install nvm
follow these instructions. Once installed, run:
nvm install --lts
- (Optional) To enable Code Splitting (importing only the SDK modules you need) there are additional prerequisites.
Install the Immutable SDK
Run the following command in your project root directory.
- npm
- yarn
npm install -D @imtbl/sdk
# if necessary, install dependencies
npm install -D typescript ts-node
yarn add --dev @imtbl/sdk
# if necessary, install dependencies
yarn add --dev typescript ts-node
Troubleshooting
The Immutable SDK is still in early development. If experiencing complications, use the following commands to ensure the most recent release of the SDK is correctly installed:
- npm
- yarn
rm -Rf node_modules
npm cache clean --force
npm i
rm -Rf node_modules
yarn cache clean
yarn install
Initialisation
Default setupView on GitHub
// Import the checkout module from the Immutable SDK package
import { checkout } from '@imtbl/sdk';
// Instantiate the Checkout SDKs with the default configurations
export const checkoutSDK = new checkout.Checkout();
Further details on the Checkout
class can be found in the Immutable SDK documentation.
Configuration
The following properties are configurations to correctly initialise the SDKs.
Property | Description |
---|---|
baseConfig | Application base configuration that specifies the application's environment . Default environment is SANDBOX . |
swap | Configure the Swap feature (e.g. enable/disable). |
bridge | Configure the Bridge feature (e.g. enable/disable). |
onRamp | Configure the On-Ramp feature (e.g. enable/disable). |
Custom setupView on GitHub
// Import the checkout and config modules from the Immutable SDK package
import { checkout, config } from '@imtbl/sdk';
// Create a new Immutable SDK configuration
// Replace with your Publishable Key from the Immutable Hub
const PUBLISHABLE_KEY = process.env.NEXT_PUBLIC_PUBLISHABLE_KEY ?? ''
// Set the environment to SANDBOX for testnet or PRODUCTION for mainnet
const baseConfig = {
environment: config.Environment.SANDBOX,
publishableKey: PUBLISHABLE_KEY,
};
// Instantiate the Checkout SDKs with the default configurations
export const checkoutSDK = new checkout.Checkout({
baseConfig,
bridge: { enable: true },
onRamp: { enable: true },
swap: { enable: true },
// passport: <optionally add Passport instance>
});