Skip to content

Tutorial

Build your first panel

Write a small community panel from an empty folder, style it with Deska’s theme, run it on your desk and get it ready to submit. About fifteen minutes.

Before you start

A community panel is a folder of web files with a panel.json at its root. Deska runs it in a sandbox, inside its own panel, and the panel talks to Deska only through window.deska. There is no build step and nothing to host. You need Deska 1.26.0 or later on your computer, a text editor and, for the optional preview tool, Node 20 or later.

The panel you build here is a clock that remembers a time zone. The finished folder is starter/ in deska-panels-examples, next to twenty-two larger examples, each teaching a different part of the SDK.

1. Make the folder and its panel.json

my-first-panel/
my-first-panel/
  panel.json
  index.html
  app.css
  app.js
  icon.svg

panel.json says what the panel is and what it may do. People read it before they install:

panel.jsonjson
{
  "schema": 1,
  "id": "my-first-panel",
  "name": "My First Panel",
  "version": "0.1.0",
  "description": "A small clock that remembers one time zone.",
  "author": "Your name",
  "icon": "icon.svg",
  "category": "other",
  "permissions": [],
  "network": [],
  "sdk": 1,
  "contributes": {
    "panel": { "entry": "index.html", "scope": "workspace", "size": { "width": 300, "height": 200 } }
  }
}
  • id is 3 to 40 lowercase letters, digits and dashes. Your first submission claims it for your account, and ids that name Deska, a coding agent or a built-in panel are refused.
  • permissions and network are empty, so this panel cannot send notices, open links, copy, or reach the internet. Ask only for what you use.

Every field, and every id that is refused, is in the panel.json reference.

2. Load the SDK

index.htmlhtml
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>My First Panel</title>
  <link rel="stylesheet" href="app.css">
  <script src="/__deska/sdk.js"></script>
  <script type="module" src="app.js"></script>
</head>
<body>
  <main>
    <p class="time" id="time">--:--</p>
    <label class="field">
      <span>Time zone</span>
      <select id="zone"></select>
    </label>
  </main>
</body>
</html>

/__deska/sdk.js is not a file in your folder. Deska serves it inside every panel, always matching the app, and it defines window.deska. Load it as a classic script before anything that uses it.

3. Style it with Deska’s theme

The SDK writes Deska’s theme on your page as CSS custom properties and updates them whenever the theme or the accent changes. Use them for every color and the panel matches dark, light and every accent:

app.csscss
body {
  margin: 0;
  background: var(--deska-bg);
  color: var(--deska-text);
  font: 13px/1.45 var(--deska-font-ui);
}

select {
  color: var(--deska-text);
  background: var(--deska-surface);
  border: 1px solid var(--deska-border);
  border-radius: var(--deska-radius-small);
}

select:focus-visible {
  outline: 2px solid var(--deska-focus);
}

The sixteen tokens and what each is for are in Theme tokens. The Theme Inspector example shows each one live, with its contrast.

4. Write the panel in five steps

app.jsjs
const $ = (id) => document.getElementById(id)

// 1. Wait for Deska: the panel, the theme, its permissions, the locale.
const init = await deska.ready()

// 2. Load what this panel saved last time. null means a first run.
let zone = (await deska.storage.get('zone')) ?? Intl.DateTimeFormat().resolvedOptions().timeZone

// 3. Render, and name the time under the panel's title on the canvas.
function render() {
  const time = new Intl.DateTimeFormat(init.locale, { timeZone: zone, timeStyle: 'short' }).format(new Date())
  $('time').textContent = time
  deska.setTitle(`${zone.split('/').pop().replaceAll('_', ' ')} ${time}`)
}

for (const name of Intl.supportedValuesOf('timeZone')) $('zone').add(new Option(name, name))
$('zone').value = zone

// 4. Save when the person changes something. Every call can fail with a code.
$('zone').addEventListener('change', async () => {
  zone = $('zone').value
  render()
  try {
    await deska.storage.set('zone', zone)
  } catch (err) {
    console.warn(`Could not save: ${err.code}`)
  }
})

// 5. Tick only while someone can see the panel.
let timer = null
function start() {
  render()
  timer = setInterval(render, 15_000)
}
deska.on('visibility', ({ visible }) => {
  clearInterval(timer)
  if (visible) start()
})
if (deska.visible) start()
else render()
  1. deska.ready() answers with the panel, the theme, its permissions and the person’s locale. Nothing from Deska works before it.
  2. deska.storage is where data lasts: the sandbox has no localStorage or cookies. Values are JSON, up to 256 KB, shared by every copy of the panel on the computer. Images and other files go in deska.files.
  3. deska.setTitle shows a line under the panel’s name on the canvas: up to 60 characters. null, an empty string or a longer title is refused with invalid_args, never cut. Set the panel’s own name, init.panel.name, to show the name alone.
  4. Every call can fail with a code, like storage_full, permission_denied or not_focused. Answer the ones a person can act on; all twelve are in Error codes and limits.
  5. deska.on('visibility') says when the panel is scrolled away, folded into a dock or behind the far view. It keeps running there, so stop timers and animations and catch up when it shows again.

A panel can reload at any time: moved to a dock, updated, Deska restarted. Keep what matters in storage and rebuild from what deska.ready() returns. Every method, with its arguments and errors, is in the SDK reference.

5. Run it on your desk

Open Build a panel (in the Marketplace, Yours › My panels › Create a panel), choose Load a folder and pick the folder that holds panel.json. Deska checks it, lists anything to fix, adds the panel to your desk and reloads it every time you save a file. The folder stays under Loaded folders, marked Ready or with its problems. Switch Deska’s theme to check both looks.

To build next to your editor without Deska, the examples repository has a preview tool that serves a panel with the same rules and plays Deska’s side of the SDK, with a log of every call:

sh
git clone https://github.com/0xPasho/deska-panels-examples.git
cd deska-panels-examples
npm install
npm run preview -- starter                 # the finished tutorial
npm run preview -- path/to/my-first-panel   # your own folder
NoteThe preview is a stand-in. Load the folder in Deska before you submit: that is the runtime your panel ships to. More ways to test, and the failures people hit most, are in Testing and debugging.

What a panel cannot do

  • Open frames itself, run workers or load scripts from the internet. To show a YouTube player or another site’s page, the panel asks Deska with deska.embed; audio and video files play from the sites you declare.
  • Reach a site that is not in network, or one that does not allow requests from any origin (CORS). The panel’s origin is opaque.
  • Send a form anywhere, open a popup or call alert(). Handle a form’s submit yourself and open links with deska.openUrl.
  • Keep a secret. There is no safe place for a token, so use public APIs.
  • Take the keyboard on its own. Focus moves only when the person uses the panel; ask for attention with deska.notify.
  • Each rule, with what to do instead, is in The sandbox.

6. Submit it

Any account signed in to Deska can submit a panel, without asking first. Before your first one, change id, name and author to your own, and add a screenshots/ folder beside panel.json with 1 to 5 images of the panel on your desk: PNG, JPEG or WebP, each at most 2 MB and 320 to 4,096 pixels on each side.

Then press Submit… on the folder in Loaded folders, say what changed and confirm. Deska reviews every version before people can install it, and its answer shows under Your panels in Build a panel. Raise version for every release: a submitted version never changes, and its number stays taken even if Deska declines it. Screenshots, review, versions, permissions people are asked for again, and unlisting are in Submitting and review.

7. Update it

Keep the id forever: it is what makes a version an update of your panel. A folder with another id is a new panel, with no installs and its own review.

  1. Raise version in panel.json. It has to be higher than every version you sent, declined ones included.
  2. In Build a panel, press Update… on the panel in Your panels.
  3. Folder. Press Load a folder, or Use this folder on one you already loaded. The folder can have any name: the update keeps the panel’s id and name.
  4. Review and submit. Check the version it goes to, what it asks for that people were not asked before, and its screenshots, then submit it.

Once Deska approves it, everyone who installed the panel gets it, and anyone it now asks for a new permission or site is asked first. More in Update a panel you published.

Build it with an agent

Dex, Claude Code, Codex or any coding agent can write the folder for you. Give it this brief with what the panel should do, then load the folder yourself: Deska’s checks, not the agent’s word, say whether it is ready.

text
Build a Deska community panel in this folder. Follow https://deska.dev/docs/build-panels.

- The folder is the panel: panel.json at its root and plain HTML, CSS and JavaScript.
  No build step, no server, no CDN: every file the panel loads lives in the folder.
- panel.json follows https://deska.dev/docs/panel-manifest: schema 1, a lowercase id that
  never changes once the panel is submitted, name, version (semver, raised for every
  release), description, author, icon, category, permissions, network, sdk and
  contributes.panel.entry.
- Load the SDK with <script src="/__deska/sdk.js"></script> and await deska.ready() before
  anything else. Talk to Deska only through window.deska (https://deska.dev/docs/panel-sdk).
  Every call can fail with an error code: handle it.
- It runs in a sandbox (https://deska.dev/docs/panel-sandbox): save state with
  deska.storage, never localStorage, indexedDB or cookies; draw icons as inline SVG.
- Style it with Deska's theme variables (--deska-bg, --deska-text, --deska-surface,
  --deska-border, --deska-focus, --deska-font-ui) so it reads in dark and light themes
  (https://deska.dev/docs/panel-theming).
- Ask for the least: list in "permissions" only what the panel uses, and in "network"
  every host it fetches from.
- To know who uses it, use Sign in with Deska (https://deska.dev/docs/panel-sign-in):
  declare "account" and ask only for the fields the panel shows (name, email, username,
  avatar).
- Add screenshots/ with 1 to 5 images of the panel before it is submitted.
- When you are done, tell me to load the folder in Deska (Build a panel, Load a folder)
  and fix every problem it lists.
NoteRead what the panel asks for before you submit. Every permission and site in panel.json is shown to the people who install it, and Deska reviews each version.