@conscience-technology/nora-relay-core
v0.1.1
Published
Shared logic for wiring the Nora Relay reporter into a site: the API client, framework detection, and the embed snippet.
Readme
@conscience-technology/nora-relay-core
The shared library behind the Nora Relay SDK: an API client for your workspace, framework detection, and the reporter embed snippet. Zero dependencies, ESM, Node 18+.
Most people want the CLI or the MCP server. Use this package directly when you're scripting your own onboarding.
Install
npm i @conscience-technology/nora-relay-coreUsage
import {
createClient,
widgetSnippet,
installWidget,
detectFramework,
} from "@conscience-technology/nora-relay-core";
// Talk to your workspace (org slug + org API key).
const client = createClient({ org: "your-workspace", key: "nrk_live_…" });
// Create a project (one client site).
const project = await client.createProject({
name: "Acme",
mainUrl: "https://acme.example.com",
repoRef: "acme/website", // optional — where fixes open PRs
});
// List projects.
const projects = await client.listProjects();
// Generate the embed snippet, customised to the site.
const snippet = widgetSnippet({
projectKey: project.projectKey,
accent: "#0075de",
position: "bottom-left",
lang: "en",
});
// Or detect the framework and place it for me.
const { kind } = await detectFramework(); // "next-app" | "next-pages" | "html" | "unknown"
const result = await installWidget({ projectKey: project.projectKey, accent: "#0075de" });
// → { inserted, file, kind, snippet }API
createClient({ api?, org, key })→{ createProject, listProjects }createProject({ name, mainUrl, repoRef?, stagingUrl?, deployTarget? })→{ projectKey, slug, name, mainUrl }listProjects()→Project[]
widgetSnippet({ projectKey, api?, scriptSrc?, lang?, accent?, position?, offsetX?, offsetY? })→stringdetectFramework(cwd?)→{ kind, file }insertSnippet(file, snippet)→{ file, inserted, already }installWidget({ cwd?, projectKey, ...look })→ detection + placementPOSITIONS→ the four allowedpositionvaluesDEFAULT_API,DEFAULT_SCRIPT
License
MIT
