Installation
Install the Packbase TypeScript SDK and check that it works in your project.
The @packbase/sdk-ts library contains reusable code for your project. Use the library to call the Packbase API.
Before you start
Use one of these environments:
- Node.js 18 or newer
- Bun
- A modern browser project with the standard
fetchAPI
TypeScript is recommended because the SDK includes TypeScript types. You can also use JavaScript. You do not have to install a separate @types package.
Install the package
Run one of the following commands from your project directory. Use the command for your package manager. If you do not know which command to use, use npm.
npm install @packbase/sdk-tsbun add @packbase/sdk-tspnpm add @packbase/sdk-tsyarn add @packbase/sdk-tsThe command adds the SDK to package.json. It also downloads the SDK to the project dependencies.
Check the installation
Create or open a TypeScript file and add:
import { PackbaseSDK } from '@packbase/sdk-ts'
const pb = new PackbaseSDK()
console.log('Packbase SDK is ready', pb)Make sure that your editor recognizes PackbaseSDK. Then, run the project. If there is no import error, the installation is correct. This example creates a client object but does not call the API.
If the import has a TypeScript error, make sure that you installed the package in the applicable project. If the error continues, set moduleResolution in tsconfig.json. Use "Bundler" or "NodeNext".
Then, complete the Quickstart to make a request.