---
title: "TypeScript SDK installation"
description: "Install the PgBeam SDK, configure the client, authenticate, and learn the two access patterns."
canonical: "https://pgbeam.com/docs/ts-sdk"
last-updated: "2026-09-14T19:37:21.000Z"
---

# TypeScript SDK installation

> Install the PgBeam SDK, configure the client, authenticate, and learn the two access patterns.

URL: https://pgbeam.com/docs/ts-sdk

## Installation

## Client setup

## Constructor options

Option

Type

Description

`token`

`string \| null \| () => Promise<string \| null>`

JWT token, API key, or async function that resolves one

`baseUrl`

`string`

Base URL of the PgBeam API

`fetch`

`typeof globalThis.fetch`

Optional custom fetch implementation

`onResponse`

`OnResponseHook`

Optional hook called after every response

## Authentication

The `token` constructor option accepts a static string, an async function, or an API key. Choose the approach that fits your environment.

See API Keys for key creation and rotation.

## Usage patterns

The SDK supports two styles for making requests: tag-based access and route-based access. Both are fully type-safe.

## Tag-based access

Methods are grouped by tag: `projects`, `databases`, `analytics`, `platform`, and `account`.

## Route-based access

Use `api.request()` with a route string for a more REST-like style:

Tag-based access is recommended for most use cases. It provides better
discoverability through IDE autocomplete. Route-based access is useful when
you want your code to mirror the REST endpoints directly.