API Reference

@google-cloud/pubsub

Google Cloud Pub/Sub client for Node.js with topic publishing, subscriptions, and ack handling.

Official Documentation ↗
CompatibilityThis documentation covers version v6.3.2. Check the official docs for the latest API surface.

Installation

npmnpm install @google-cloud/pubsub

Methods

The Pub/Sub client publishes to topics and delivers messages through subscriptions with automatic acking.

Key Features

  • Promise-based publish with message ids
  • Streaming pull subscriptions
  • Flow control and ack deadlines

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

What happens if I never ack?
The message is redelivered after the ack deadline expires, so handlers should be idempotent because at-least-once delivery can repeat.
How do I control throughput?
Set flowControl options such as maxMessages on the subscription so the client does not pull more than the handler can process.
Should I use pull or push?
Pull subscriptions fit workers that control their own rate; push subscriptions deliver to an HTTPS endpoint and suit serverless handlers.