@smarthivelabs-devs/mailer-sdk-browser
v1.1.0
Published
SmartHive Mailer SDK for browser / React applications
Readme
@smarthivelabs-devs/mailer-sdk-browser
Browser-safe client for the Smart Hive mailer platform. Use this in React, Next.js, or any frontend application.
This package only supports bearer token auth. It refuses appApiKey and internalService modes at runtime so your API keys and internal secrets can never be exposed in client-side code.
Installation
npm install @smarthivelabs-devs/mailer-sdk-browser
# or
pnpm add @smarthivelabs-devs/mailer-sdk-browserRequirements: Node.js ≥ 18 (or any modern browser with fetch) · TypeScript ≥ 5.0
Quick Start
import { createMailerBrowserClient } from '@smarthivelabs-devs/mailer-sdk-browser';
// Authenticated — use the user's session token
const client = createMailerBrowserClient({
baseUrl: process.env.NEXT_PUBLIC_MAILER_URL!,
auth: {
mode: 'bearerToken',
token: userSession.accessToken,
},
});
// Unauthenticated — health checks, public docs
const publicClient = createMailerBrowserClient({
baseUrl: process.env.NEXT_PUBLIC_MAILER_URL!,
});Usage
// Health check
const health = await client.health.get();
// { status: 'ok', timestamp: '...', services: { db: 'ok', redis: 'ok' } }
// OpenAPI spec
const spec = await client.docs.getOpenApi();
// In-app notifications for the current user
await client.notifications.send({
channel: 'IN_APP',
recipient: currentUser.id,
title: 'Task assigned',
body: 'You have been assigned to Project Alpha.',
data: { projectId: 'proj_xyz' },
});What this package blocks
The browser client will throw at runtime if you try to use appApiKey or internalService auth. Those modes send privileged credentials — they belong server-side only, in @smarthivelabs-devs/mailer-sdk-server.
Exports
createMailerBrowserClient(options)— main factoryMailerBrowserClient— client typeMailerBrowserClientOptions— options typeBearerTokenAuth— auth mode type
All types are included in this package — no additional install needed. For server-side usage: @smarthivelabs-devs/mailer-sdk-server
