Install and connect

Install and connect

The Go and TypeScript SDKs connect your code to Nova and handle routing, batching, and retries for you.

This tab is for developers who use Nova from Go or TypeScript. Each example also has an HTTP tab with the same request in curl, for code that calls the API directly. An SDK does more than call the API: it batches your appends, keeps several batches in flight, retries a failed call for up to 30 seconds, sends each call to the node that serves the stream, and returns typed errors.

Packages

GoTypeScript
Packagegithub.com/supabase/nova/client@supabase/nova, plus one transport package
Installgo get github.com/supabase/novanpm install @supabase/nova, plus a transport package
Runs onGo 1.27 or laterNode.js 22 or later; browsers and edge runtimes over HTTP
TransportgRPC or HTTP, chosen by the addressgRPC with @supabase/nova-transport-grpc, HTTP with @supabase/nova-transport-http
Referencepkg.go.devREADME

Both SDKs follow the same model and have the same errors and retry rules. Names follow each language: OpenStream in Go is openStream in TypeScript.

Install

go get github.com/supabase/nova

Then import github.com/supabase/nova/client.

Connect

Create one client per process and share it. A client is safe for concurrent use, and it connects on its first call.

c, err := client.New(client.Options{
	Addrs: []string{"localhost:7781"}, // any node of the cluster
})
if err != nil {
	return err
}
defer c.Close()

Every call takes a context.Context first; cancel it to stop the call. Errors wrap sentinel values such as client.ErrUnavailable, so check them with errors.Is. Close releases the connections and ends every producer the client opened.

Where to connect

A client connects to a node over gRPC, or to a node or the Gateway over HTTP. The address you give picks the transport:

TargetAddressUse when
A node, over gRPChost:port, such as localhost:7781Your code runs on the same network as the nodes. This is the default.
A node's data bridge, its HTTP listenerhttp://host:port, such as http://localhost:7791Your network allows only HTTP to the nodes
The Gatewayhttps://{location}.{domain}, or http://localhost:8080 in the local clusterYour code runs outside the cluster's network: on the internet, in a browser, or in an edge function
TargetGo optionTypeScript transport
A node, over gRPCAddrscreateGrpcTransport({ addrs })
A node's data bridgeURLcreateHttpTransport({ url })
The GatewayDomain and Location, or URLcreateHttpTransport({ domain, location }), or { url }

One address is enough. Any node serves reads, and for writes it points the client to the right node. Extra addresses are fallbacks for when a connection fails. A client uses one transport. Each transport refuses the other's address form, and a TLS setting beside an http:// address.

The Gateway can also end TLS, check tokens, and admit browsers from the origins you list.

HTTP has two limits. The admin calls need gRPC, so over HTTP they fail with ErrWireOnly / WireOnlyError before anything is sent. A browser cannot keep a producer session open, because its fetch waits for the request body to end. There, openStream fails with SessionUnsupportedError, so use one-shot appends.

Authenticate

In production, clients usually reach Nova through the Gateway and authenticate with an api key. The SDK exchanges the key for short-lived tokens and renews them on its own.

// The client connects to https://eu-central-1.nova.example.com.
c, err := client.New(client.Options{
	Domain:   "nova.example.com",
	Location: "eu-central-1",
	Auth:     client.APIKey(client.APIKeyCredential{Key: os.Getenv("NOVA_API_KEY")}),
})
if err != nil {
	return err
}
defer c.Close()

The other credentials are client.Bearer, client.BearerFunc, and client.BasicAuth. A malformed api key makes client.New fail with client.ErrMalformedAPIKey.

Options you set always win. Without them, a client reads its address from NOVA_DOMAIN or NOVA_ADDR, its location from NOVA_LOCATION, and its api key from NOVA_API_KEY; Client options gives the order. How clients authenticate explains keys, tokens, and scopes.

Routing to the leader

One node serves each stream's writes: the stream's leader. When a node is not the leader, it replies with the leader's address. The SDK follows that reply and remembers the leader for later calls. It forgets the leader when that node says it no longer leads, cannot be reached, or lets three calls in a row run out of time. Over HTTP, the node or the Gateway does the routing for you.

The reply names the leader's advertised address, which must resolve where your code runs. Otherwise the call fails at once with ErrHolderUnresolvable / HolderUnresolvableError, and no retry helps until the operator fixes the address.

Retries

The SDK retries a call that fails for a passing reason, such as a restarting or busy node, for up to its retry budget, 30 seconds by default; management calls are sent once, and over plain HTTP nothing retries for you. What the SDK retries has the rules, and Reconnects explains why a producer that reconnects can store a batch twice.

How the SDK is organised

You start with a client, which you configure once. A stream is named by its address, a bucket and a key (client.Address{Bucket, Key} / { bucket, key }). Create and manage buckets and streams first. To write, append records with a producer or in one call. To read, read a page or subscribe to new records. Coordinate writers with a match sequence number or a fencing token, and trim and delete what you no longer need. To spread one stream's writes over ranges, use a scalable stream. For work queues, send messages, run a worker, and handle retries and dead letters. Handle errors lists every error and what to do about it.

On this page