SegmentStream
@segmentstream-cloud/app

Ship an internal app in one deploy. Sign-in and data included.

Build the BI app your team needs, from dashboards to workflows and approvals, as a Next.js app in your workspace repo. The SDK handles sign-in, sessions, warehouse queries and metrics, and segmentstream deploy puts it online. Your agent writes it and you open the link.

Get started

terminal
$ npm install @segmentstream-cloud/app

At a glance

  • Next.js App Router, version 16 or later
  • Sign-in with PKCE; 5-minute ES256 session tokens, rotating refresh
  • Apps never hold warehouse or identity-provider credentials
  • Apache-2.0

What it does

01

Sign-in in three files

Three files and every page is behind SegmentStream sign-in. Only members of the workspace's organization get in; the app never handles their credentials.

three files
// src/segmentstream.ts
export const segmentstream = createSegmentStreamApp({
  workspaceId: "your-workspace-id",
  organizationId: "your-organization-id",
});

// src/proxy.ts
export const proxy = segmentstream.proxy({ publicPaths: ["/health"] });

// src/app/api/segmentstream/[...path]/route.ts
export const { GET, POST } = segmentstream.handlers();
02

Know who is visiting

Read who is visiting in any Server Component, Route Handler or Server Function.

src/app/page.tsx
export default async function Page() {
  const user = await segmentstream.requireUser();
  return <p>Signed in as {user.email ?? user.id}</p>;
}
03

Query the warehouse

Read-only SQL over the workspace warehouse, with typed named parameters. Queries run with the workspace's identity; the browser never sees a key.

src/app/revenue.tsx
const { rows } = await segmentstream.warehouse.query<Revenue>(
  `SELECT order_date, total_revenue
     FROM gold.revenue_summary
    WHERE order_date >= @from
    ORDER BY order_date`,
  { params: { from: sql.date("2026-09-01") } },
);
04

Metrics without SQL

Ask for measures and dimensions instead of writing SQL. Every app, report and agent gets the same definition of spend.

src/app/spend.tsx
const { rows } = await segmentstream.semantic.query("advertising", {
  dimensions: ["platform"],
  measures: ["spend", "clicks"],
  dateRange: { from: "2026-09-01", to: "2026-09-30" },
  filters: [{ dimension: "currency", operator: "equals", value: "USD" }],
});
05

Big queries without timeouts

Estimate a query before running it, and resume long queries from a later request instead of holding one open.

src/app/api/report/route.ts
const estimate = await segmentstream.warehouse.dryRun(query);

try {
  return await segmentstream.warehouse.query(query, { timeoutMs: 20_000 });
} catch (error) {
  if (error instanceof SegmentStreamApiError && error.queryId) {
    return segmentstream.warehouse.result(error.queryId); // poll later
  }
  throw error;
}
06

Act as the member

The session token works on the whole SegmentStream API with the visitor's own role, so an app can do anything that person may do and nothing more.

src/app/datasets.tsx
const response = await segmentstream.fetch(
  `/api/v1/workspaces/${user.workspaceId}/warehouse/datasets`,
);
07

Durable workflows

Long-running work such as exports, syncs and approvals runs as durable workflows with retries, inside the same app.

src/workflows/export-report.ts
export async function exportReport(input: { month: string }) {
  "use workflow";
  const rows = await loadRows(input.month);
  return deliver(rows);
}

async function loadRows(month: string) {
  "use step";
  // queried once, retried on failure
}
08

Deploy with one command

segmentstream deploy builds the app remotely and prints its URL. You don't need a hosting account, a server or copied secrets. Every pull request gets a preview.

terminal
$ segmentstream deploy
▸ building app · pipeline · connections
▸ app ready at https://acme-analytics.segmentstream.app

The rest of the surface

Your company’s context, ready for every agent.

$ segmentstream workspace create acme --region eu

▸ workspace ready · data, objects, metrics and access rules in one place

▸ connect Claude, ChatGPT or Cursor with one connector

▸ tell your agent: “add our billing API as a source”

Start a pilot

Our engineers build the first version on your data in two weeks, at a fixed price.

Or join the waitlist for self-serve:

Pilots are open now. Self-serve opens to the waitlist this fall.