HOST
Ohne Framework
Eine statische Seite kann den Chat öffnen. Irgendetwas auf Ihrem Origin muss das Token minten.
Ohne Framework
Eine statische Seite kann den Chat öffnen. Irgendetwas auf Ihrem Origin muss das Token minten.
Einbettung mit statischem HTML, iframe, <sveda-chat> oder ein paar Zeilen PHP/Node-HTTP.
AGENT PROMPT
Paste into Cursor
Copy this into Cursor, Claude Code, or any coding agent. It installs Sveda against this stack using public packages.
Install Sveda into this project with no framework.
Read:
- https://sveda.dev/docs/hosts/vanilla
- https://sveda.dev/docs/embed
- https://sveda.dev/docs/deploy
- https://sveda.dev/llms.txt
Follow the numbered steps on the vanilla page. If unsure where to put the session endpoint, ask the user. 1. Run sveda-server
Token minting is off until
SVEDA_EMBED_ENABLED=true.
Run the published image
ghcr.io/neresson/sveda-server:latest
— do not cargo-build unless you are developing the runtime.
Put your page origin in
SVEDA_CORS_ORIGINS
or the browser cannot load the widget CSS/JS.
Full bind and routes:
runtime.
# ghcr.io/neresson/sveda-server:latest
# curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.yaml -o compose.yaml && curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.env -o .env && # Edit .env: a model key, SVEDA_EMBED_HOST_API_KEY, SVEDA_CORS_ORIGINS && && docker compose up -d && curl -s http://127.0.0.1:8787/sveda/ready
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: sveda
POSTGRES_PASSWORD: sveda
POSTGRES_DB: sveda
healthcheck:
test: ["CMD-SHELL", "pg_isready -U sveda -d sveda"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- sveda-postgres:/var/lib/postgresql/data
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
sveda-server:
image: ghcr.io/neresson/sveda-server:latest
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8787:8787"
environment:
SVEDA_BIND: 0.0.0.0:8787
SVEDA_EMBED_ENABLED: "true"
SVEDA_DATABASE_URL: postgres://sveda:sveda@postgres:5432/sveda
SVEDA_REDIS_URL: redis://redis:6379
SVEDA_APP_KEY: ${SVEDA_APP_KEY:-dev-app-key-change-me}
SVEDA_ADMIN_API_KEY: ${SVEDA_ADMIN_API_KEY:-dev-admin-key-change-me}
SVEDA_EMBED_HOST_API_KEY: ${SVEDA_EMBED_HOST_API_KEY:-dev-host-key-change-me}
SVEDA_CORS_ORIGINS: ${SVEDA_CORS_ORIGINS:-*}
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
volumes:
sveda-postgres:# ghcr.io/neresson/sveda-server:latest
# curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.yaml -o compose.yaml && curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.env -o .env && # Edit .env: a model key, SVEDA_EMBED_HOST_API_KEY, SVEDA_CORS_ORIGINS && && docker compose up -d && curl -s http://127.0.0.1:8787/sveda/ready
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: sveda
POSTGRES_PASSWORD: sveda
POSTGRES_DB: sveda
healthcheck:
test: ["CMD-SHELL", "pg_isready -U sveda -d sveda"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- sveda-postgres:/var/lib/postgresql/data
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
sveda-server:
image: ghcr.io/neresson/sveda-server:latest
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8787:8787"
environment:
SVEDA_BIND: 0.0.0.0:8787
SVEDA_EMBED_ENABLED: "true"
SVEDA_DATABASE_URL: postgres://sveda:sveda@postgres:5432/sveda
SVEDA_REDIS_URL: redis://redis:6379
SVEDA_APP_KEY: ${SVEDA_APP_KEY:-dev-app-key-change-me}
SVEDA_ADMIN_API_KEY: ${SVEDA_ADMIN_API_KEY:-dev-admin-key-change-me}
SVEDA_EMBED_HOST_API_KEY: ${SVEDA_EMBED_HOST_API_KEY:-dev-host-key-change-me}
SVEDA_CORS_ORIGINS: ${SVEDA_CORS_ORIGINS:-*}
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
volumes:
sveda-postgres: 2. Keep the host key on the server
The browser never sends
SVEDA_EMBED_HOST_API_KEY.
Local-only, you can mint with curl. In anything users will load, add a tiny
POST /sveda/session
on the same origin as the page.
SVEDA_CLIENT_BASE_URL=http://127.0.0.1:8787
SVEDA_CLIENT_HOST_API_KEY=replace-meSVEDA_CLIENT_BASE_URL=http://127.0.0.1:8787 SVEDA_CLIENT_HOST_API_KEY=replace-me
curl -s http://127.0.0.1:8787/sveda/embed/token \
-H 'content-type: application/json' \
-H 'authorization: Bearer replace-me' \
-d '{"visitor_id":"local-dev"}'curl -s http://127.0.0.1:8787/sveda/embed/token \
-H 'content-type: application/json' \
-H 'authorization: Bearer replace-me' \
-d '{"visitor_id":"local-dev"}' 3. Tiny session endpoint (no framework)
Any host that can POST JSON is enough. Return this shape — it is what
sveda-host.js
expects. PHP built-in server, Node
http.createServer,
or a CGI script all work. Handshake:
embed token.
{
"origin": "http://127.0.0.1:8787",
"token": "sveda_embed_…",
"expires_in": 3600,
"appearance": null
}{
"origin": "http://127.0.0.1:8787",
"token": "sveda_embed_…",
"expires_in": 3600,
"appearance": null
} <?php
$origin = rtrim(getenv('SVEDA_CLIENT_BASE_URL') ?: '', '/');
$key = getenv('SVEDA_CLIENT_HOST_API_KEY') ?: '';
$ch = curl_init($origin.'/sveda/embed/token');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'authorization: Bearer '.$key,
],
CURLOPT_POSTFIELDS => json_encode(['visitor_id' => 'html-host']),
CURLOPT_RETURNTRANSFER => true,
]);
$mint = json_decode(curl_exec($ch), true);
header('content-type: application/json');
echo json_encode([
'origin' => $origin,
'token' => $mint['token'] ?? '',
'expires_in' => $mint['expires_in'] ?? 3600,
'appearance' => $mint['appearance'] ?? null,
]);<?php
$origin = rtrim(getenv('SVEDA_CLIENT_BASE_URL') ?: '', '/');
$key = getenv('SVEDA_CLIENT_HOST_API_KEY') ?: '';
$ch = curl_init($origin.'/sveda/embed/token');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'authorization: Bearer '.$key,
],
CURLOPT_POSTFIELDS => json_encode(['visitor_id' => 'html-host']),
CURLOPT_RETURNTRANSFER => true,
]);
$mint = json_decode(curl_exec($ch), true);
header('content-type: application/json');
echo json_encode([
'origin' => $origin,
'token' => $mint['token'] ?? '',
'expires_in' => $mint['expires_in'] ?? 3600,
'appearance' => $mint['appearance'] ?? null,
]); 4. Iframe (no JS SDK)
After you have a token, point an iframe at
/sveda/embed?token=
on the sidecar. No npm package, no web component.
<iframe
title="Sveda"
src="http://127.0.0.1:8787/sveda/embed?token=sveda_embed_…"
allow="clipboard-write"
style="position:fixed;right:20px;bottom:0;width:400px;height:640px;border:0;background:transparent"
></iframe><iframe title="Sveda" src="http://127.0.0.1:8787/sveda/embed?token=sveda_embed_…" allow="clipboard-write" style="position:fixed;right:20px;bottom:0;width:400px;height:640px;border:0;background:transparent" ></iframe>
5. In-DOM web component
Load CSS then JS from the sidecar
/build/sveda/
prefix. Do not import the CSS as a JS module.
session
is your mint URL. Call
element.open()
from a host button, or omit
hide-launcher
to use the built-in launcher.
<link rel="stylesheet" href="http://127.0.0.1:8787/build/sveda/sveda-chat.css" />
<script type="module" src="http://127.0.0.1:8787/build/sveda/sveda-chat.js"></script>
<sveda-chat session="/sveda/session" hide-launcher></sveda-chat><link rel="stylesheet" href="http://127.0.0.1:8787/build/sveda/sveda-chat.css" /> <script type="module" src="http://127.0.0.1:8787/build/sveda/sveda-chat.js"></script> <sveda-chat session="/sveda/session" hide-launcher></sveda-chat>
6. Host buttons (JS + iframe)
Serve a copy of
sveda-host.js
from your origin. It reads
data-sveda-origin
and
data-sveda-session,
POSTs for a token, then either mounts
<sveda-chat>
or an iframe. Hide the buttons when the origin env is empty.
<html
lang="en"
data-sveda-origin="http://127.0.0.1:8787"
data-sveda-session="/sveda/session"
>
<body>
<button type="button" data-sveda-open="js">Open JS chat</button>
<button type="button" data-sveda-open="iframe">Open iframe chat</button>
<script type="module" src="/sveda-host.js"></script>
</body>
</html><html
lang="en"
data-sveda-origin="http://127.0.0.1:8787"
data-sveda-session="/sveda/session"
>
<body>
<button type="button" data-sveda-open="js">Open JS chat</button>
<button type="button" data-sveda-open="iframe">Open iframe chat</button>
<script type="module" src="/sveda-host.js"></script>
</body>
</html>