Skip to main content

Connect RPC

Use the Buf Schema Registry (BSR) to install auto-generated, type-safe clients for your language.
Supported Languages: TypeScript/JavaScript, Python, Go, Swift, Kotlin, Dart
Best For: Advanced users who want direct access to the RPC protocol with full type safety

Installation

# Configure npm to use Buf registry
npm config set @buf:registry https://buf.build/gen/npm/v1

# Install generated SDK + runtime
npm install @buf/simpleemailapi_public.bufbuild_es \
            @buf/simpleemailapi_public.connectrpc_es \
            @connectrpc/connect @connectrpc/connect-web @bufbuild/protobuf

Usage Examples

import { createClient } from "@connectrpc/connect";
import { createConnectTransport } from "@connectrpc/connect-node";
import { EmailService } from "@buf/simpleemailapi_public.connectrpc_es/v1/email_connect";

const transport = createConnectTransport({
  baseUrl: "https://api.simpleemailapi.dev",
  httpVersion: "2",
  interceptors: [
    (next) => async (req) => {
      req.header.set("Authorization", "Bearer sea_live_...");
      return next(req);
    },
  ],
});

const client = createClient(EmailService, transport);

const res = await client.sendEmail({
  from: "[email protected]",
  to: ["[email protected]"],
  subject: "Hello!",
  body: "This is a test email.",
});

console.log(res.messageId);

Key Mapping (TypeScript)

SourcePackage NameImport Path
Messages@buf/simpleemailapi_public.bufbuild_es.../v1/email_pb
Services@buf/simpleemailapi_public.connectrpc_es.../v1/email_connect
File Extensions: If you are using ES Modules (modern Node.js or Vite), you may need to add the .js extension to your imports even in TypeScript: import { EmailService } from "@buf/.../v1/email_connect.js";