Run it
View Sourcemix setup # deps, tailwind/esbuild (codesigns the tailwind binary on macOS)
mix phx.server # http://localhost:4000 → /admin/setup creates the owner
Dev defaults to the in-memory store (WRAITH_STORE=memory), so nothing persists
across restarts. For a real table:
docker compose up -d # DynamoDB Local (in-memory)
export WRAITH_STORE=dynamo DYNAMO_ENDPOINT=http://127.0.0.1:8000
mix wraith.table # creates `wraith` (idempotent)
mix phx.server
Against AWS: WRAITH_STORE=dynamo AWS_PROFILE=… AWS_REGION=… mix wraith.table.
PostgreSQL or Aurora DSQL instead — same one-table layout, same mix wraith.table:
docker compose up -d postgres
WRAITH_STORE=postgres DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5434/wraith mix wraith.table
WRAITH_STORE=postgres DATABASE_URL=… mix phx.server
WRAITH_STORE=dsql DSQL_ENDPOINT=<cluster>.dsql.eu-central-1.on.aws AWS_PROFILE=… mix wraith.table
DSQL authenticates with an IAM token minted per connection (dsql:DbConnectAdmin,
Wraith.Store.SQL.Token); the index is created ASYNC, a 40001 commit conflict
is retried. All env vars are listed in .env.example; config/runtime.exs reads them.
Coming from Ghost
Export your site in Ghost (Settings → Labs → Export) and upload the JSON at
/admin/integrations (or POST /api/admin/db). Posts (HTML bodies turned into
Markdown), pages, tags, authors (random passwords, reset by mail) and members
come across; existing slugs and emails are skipped. The Content API at
/api/content/* answers in Ghost's JSON shape, so front-ends written against
Ghost's Content API need a key swap and little else — widgets appear as
<div class="wraith-widget" data-widget=… data-props=…> placeholders.
Writing
Posts are Markdown (GFM). Drop a widget in on a line of its own:
{{widget poll question="Tabs or spaces?" options="Tabs|Spaces" id=tabs}}
{{widget counter label="Readers who agree"}}
{{widget countdown to=2027-01-01 label="Launch"}}
{{widget reactions}}
{{widget live-visitors}}id= names the instance so several posts can share one state. The editor
palette inserts shortcodes; the preview runs the real widgets.
Scripting a widget
/admin/widgets/new — a Lua chunk with three functions, a clickable preview
of the unsaved source, and a version per save:
function init(props) return { claps = 0 } end
function render(state, props, meta)
return '<button class="w-btn" ' .. wraith.action("clap") .. '>👏 '
.. wraith.format(state.claps) .. '</button>'
end
function handle(state, event, payload, meta)
if event == "clap" then state.claps = state.claps + 1 end
return state
endmeta.visitor is a stable per-browser id (one vote per reader),
meta.presence the readers on the page, meta.private this reader's own
table (return it as handle's second value). Helpers: wraith.action,
wraith.escape, wraith.format, wraith.split, wraith.json,
wraith.now, and wraith.fetch(url) for hosts the owner allowlists in
Settings (cached 60 s). tick = 30 at the top re-renders every 30 s. The
sandbox removes os/io/require, cuts a call off after 250 ms, caps the
shared state at 64 KB and sanitises the HTML a widget emits. Elixir widgets
implement Wraith.Widgets.Widget and are listed in Wraith.Widgets.builtin_modules/0.