SynapSynapDocs
DevelopmentSDK

First queries with the SDK

Call your pod from React, TypeScript, or cURL — after you have a URL, workspace, and API key

First queries with the SDK

Prerequisites: a running data pod (see Installation), your pod URL, workspace ID, and an API key.

API keys: Synap app → Workspace Settings → Developer → API keys → Generate.


Option A — React

1. Install

npm install @synap/react

2. Provider

import { SynapProvider } from "@synap/react";
 
export default function App({ children }) {
  return (
    <SynapProvider
      podUrl="https://your-pod.example.com"
      apiKey="sk_live_..."
      workspaceId="ws_..."
    >
      {children}
    </SynapProvider>
  );
}

3. Read & write

import { useSynap } from "@synap/react";
 
export function NoteList() {
  const { data, isLoading } = useSynap().entities.list.useQuery({
    profileSlug: "note",
    limit: 20,
  });
  if (isLoading) return <p>Loading…</p>;
  return (
    <ul>
      {data?.items.map((note) => (
        <li key={note.id}>{note.title}</li>
      ))}
    </ul>
  );
}

Option B — TypeScript (no React)

npm install @synap/sdk
import { createSynapClient } from "@synap/sdk";
 
const synap = createSynapClient({
  podUrl: "https://your-pod.example.com",
  apiKey: "sk_live_...",
  workspaceId: "ws_...",
});
 
const entities = await synap.entities.list.query({ limit: 20 });
const created = await synap.entities.create.mutate({
  profileSlug: "note",
  title: "Hello from the SDK",
});

Option C — cURL

tRPC is exposed over HTTP at /trpc:

curl "https://your-pod.example.com/trpc/entities.list?input=%7B%22limit%22%3A5%7D" \
  -H "Authorization: Bearer sk_live_..." \
  -H "x-workspace-id: ws_..."

Types

import type { RouterInputs, RouterOutputs } from "@synap/sdk";

Next

On this page