Guides / For developers

For developers

The embed script, template syntax, JavaScript API, REST API and CLI.

8 min read

The embed script

<script src="https://cms.devdwell.com/embed.js" data-project="PROJECT_ID" defer></script>

Options: data-live="30" re-fetches every 30 seconds; data-locale="en-GB" sets date and number formatting; data-src="content.json" reads a static export instead of the API. Only published entries are returned. Elements are hidden until rendered, then get the dw-ready class (dw-empty when nothing matched).

Websites set up before the rename keep working: the older data-lumi-* attributes, lumi-* classes, lumi:* events and the Lumi object are still supported, and the embed address on cms.lumiave.com still works.

Lists and single entries

<div data-dw-list="posts" data-limit="6" data-sort="-date" data-filter="featured=true" data-empty="No posts yet">
  <template>
    <a href="/post?slug={{slug}}">
      <img data-dw-src="cover">
      <h3>{{title}}</h3>
      <p>{{author.name}} · {{date|date}}</p>
    </a>
  </template>
</div>

<article data-dw-entry="posts" data-slug-param="slug" data-dw-title="{{title}} · Blog">
  <h1>{{title}}</h1>
  <div data-dw-md="body"></div>
</article>

Template reference

SyntaxDoes
data-dw-list="type"Repeat the inner <template> per entry. data-limit, data-offset, data-sort="-date,title", data-filter="a=b;c!=d", data-empty
data-dw-entry="type"One entry via data-slug, data-id, data-slug-param, data-id-param, data-slug-from="path", or the first/singleton
{{field}}, {{a.b}}Text in content or attributes; references resolve automatically
{{x|filter}}date, date:short, datetime, upper, lower, truncate:120, default:Text, strip, number, money:USD, json, count, url
data-dw-html / data-dw-mdSanitised rich text / Markdown rendered to HTML
data-dw-src, data-dw-href, data-dw-bgImage source + alt + size, link target, background image
data-dw-each="field"Repeat children for each item of a list, gallery, repeater or references ({{.}}, {{$index}}, {{$number}})
data-dw-if="field"Keep only when set; also field=value, field!=value, !field. Page-builder sections: _block=hero

JavaScript API

const posts = await Devdwell.list('posts', { limit: 5, sort: '-date', filter: { featured: true } });
const post  = await Devdwell.get('posts', { slug: 'hello-world' });
const html  = Devdwell.markdown('## Hello');
Devdwell.render(el);            // render markup added later
await Devdwell.refresh();       // fetch the latest content
document.addEventListener('dw:ready', (e) => console.log(e.detail.entries));

REST API

curl 'https://cms-api.devdwell.com/public/PROJECT_ID/entries?type=posts'

Returns [{ id, type, slug, data, published_at, updated_at }] for published entries. Authenticated endpoints (projects, content types, entries, assets) accept Authorization: Bearer lmv_… API tokens.

Devdwell and the CLI

Sites built in the Devdwell app can create and fill CMS projects directly. Sign the helper in once with node ~/.claude/skills/devdwell-cms/cms.mjs login, then ask Devdwell to “make this site’s content editable”. The helper also works on its own: lumi projects, lumi save-type, lumi save-entries --publish, lumi upload, lumi embed. Run lumi help for everything.