Skip to content
  • SDKs
  • Server Side
  • JavaScript

Server-side JS SDK

The Hop server-side JS SDK allows you to interact with all Hop products on the server side. Currently, the SDK is compatible with Bun, Node.js and Deno.

Installing

# NPM
npm i @onehop/js
 
# Or with Yarn
yarn add @onehop/js
 
# Or with Bun
bun add @onehop/js

Or in Deno, we recommend serving from jspm.dev. This will ensure dependencies are bundled and cached for you.

import {Hop} from 'https://jspm.dev/@onehop/js@<version>';

Creating an SDK Instance

To use the SDK, you must first create a project token. You can also use a PAT (personal access token), however this is not recommended as it has access to all of your projects.

import { Hop } from '@onehop/js';
 
const myToken = 'ptk_xxx';
 
// Export the Hop SDK instance so you can use it throughout your codebase
export const hop = new Hop(myToken);
 
// Example: Creating a project secret
await hop.projects.secrets.create(
    'RANDOM_NUMBER',
    Math.floor(Math.random() \* 100).toString(),
);
Last updated on September 21, 2022