Skip to main content

Initialize SDK

HexabaseClient is the root object when operating Hexabase.

Importing HexabaseClient

Import HexabaseClient from @hexabase/hexabase-js.

import { HexabaseClient }  from '@hexabase/hexabase-js';

Initialization of HexabaseClient

To initialize HexabaseClient, use the new operator. Hexabase is now ready for use.

const client = new HexabaseClient();

Initialization options

The following parameters can be specified when initializing HexabaseClient. All are optional.

Option NameDescription
envEnvironment name. If omitted, the production environment settings will be applied. Specifying dev sets the staging environment.
urlSpecify the endpoint URL of the GraphQL API.
restSpecify the endpoint URL of the REST API.
sseSpecify the endpoint URL for PubSub.

When using Hexabse in a staging environment, initialize it as follows:

const client = new HexabaseClient({
env: 'dev',
});

To customize URLs in detail, initialize it as follows:

const client = new HexabaseClient({
env: 'dev', // The base is a staging environment
url: 'https://api.stg.hexabase.com/graphql', // Customize only the GraphQL endpoint
});