Interactive Apps in Your Markdown Notes
EtherPK (https://app.etherpk.com) keeps your notes as plain Markdown. A note can now hold client side apps, written into fenced code blocks with the app language name. This could be (for example) a calculator, a quiz, a chart, a model in 3D.
It can be used in conjunction with EtherPK agent integration so that agents can write formal verification reports with the same fidelity and interactivity that you might use a Claude Artifact for (the advantage with EtherPK, is that the output is in a format and knowledge base that you own, rather than being dependent on a subscription.
Apps are written as HTML /JS in a fenced block marked app, and runs in place of the fenced code block when you leave edit mode.
You can try interactive apps on the https://app.etherpk.com/demo - search for "Interactive Apps" to find the live demonstration.
The blog you are reading now is published from an EtherPK graph, and this page include 3 small apps that were written in fenced code blocks in the source document and you can now see running on this page. Each app has its code underneath.

What an app is
An app is a fenced block with the word app after the backticks. Inside is ordinary HTML, with <style> and <script> if you want them:
app
<title>Bean counter</title>
<button id="sow">Sow a bean</button> <output id="count">0</output>
<script type="module">
let sown = 0
document.getElementById('sow').addEventListener('click', () => {
document.getElementById('count').textContent = String(++sown)
})
</script>
In EtherPK, with the cursor on any other line, you see the app in place of the code, under a bar that reads App and the app's name. Click Edit code in the bar and you get the block back. Change something, move the cursor away, and the app starts again from the new code. Run again starts the app from the beginning without an edit.
The <title> is the app's name, and it's optional. A block needs nothing beyond its HTML.
A published page has no Edit code, which is why the code is printed here.
A calculator
The first app works out how often to water a pot, from the pot's size and the warmth of the room. It needs no library. Move the sliders:
Its code in full:
<title>Watering calculator</title>
<style>
body { display: grid; gap: 14px; max-width: 32rem; }
label { display: grid; grid-template-columns: 9.5rem 1fr 4.5rem; gap: 10px; align-items: center; }
input[type="range"] { accent-color: var(--app-accent); }
p { margin: 0; }
#days { font-size: 2rem; font-weight: 600; }
small { color: var(--app-muted); font-size: 14px; }
</style>
<label>Pot volume <input id="litres" type="range" min="0.5" max="10" step="0.5" value="1"> <span id="litresValue"></span></label>
<label>Room temperature <input id="celsius" type="range" min="10" max="32" step="1" value="18"> <span id="celsiusValue"></span></label>
<p>Water about every <output id="days" for="litres celsius"></output> days.</p>
<small>Check the soil first. The formula has never met your plant.</small>
<script type="module">
const litres = document.getElementById('litres')
const celsius = document.getElementById('celsius')
function show() {
const days = (7 * litres.value) / (1 + 0.05 * (celsius.value - 18))
document.getElementById('litresValue').textContent = `${litres.value} l`
document.getElementById('celsiusValue').textContent = `${celsius.value} °C`
document.getElementById('days').textContent = days.toFixed(days < 10 ? 1 : 0)
}
litres.addEventListener('input', show)
celsius.addEventListener('input', show)
show()
</script>
The var(--app-accent) and var(--app-muted) in the styles are colours EtherPK hands the app, so the app matches the page around it in the light and the dark theme. There are five: --app-background, --app-text, --app-muted, --app-border and --app-accent.
Those colours, the system font and a little padding are all the styling EtherPK gives an app. Nothing from EtherPK's own stylesheets, or from this site's theme, gets inside the frame, and the app's own <style> can change any of it. The app can't load a stylesheet or a font from the web, so its styles go in the block. On a published page like this one, the colours are EtherPK's own light or dark set, picked by your device's light or dark setting.
Nothing in the block sets a height, so the app is as tall as its content.
A quiz
An app is a good fit for the kind of thing you'd otherwise only read. Here's a quiz of three questions:
And its code:
<title>Watering quiz</title>
<style>
body { max-width: 34rem; }
h2 { margin: 0 0 12px; font-size: 1.1rem; }
button { display: block; width: 100%; margin: 8px 0; padding: 10px 12px; text-align: left; font: inherit; color: inherit; background: none; border: 1px solid var(--app-border); border-radius: 8px; cursor: pointer; }
button:hover:enabled { border-color: var(--app-accent); }
button.right { border-color: #16a34a; }
button.wrong { border-color: #dc2626; }
#said { min-height: 1.5em; margin: 12px 0 0; color: var(--app-muted); }
</style>
<h2 id="question"></h2>
<div id="answers"></div>
<p id="said" role="status"></p>
<script type="module">
const questions = [
{ ask: 'When should you water a houseplant?', answers: ['Every Sunday', 'When the soil is dry a few centimetres down', 'When the leaves droop'], right: 1 },
{ ask: 'What do yellow leaves most often mean?', answers: ['Too much water', 'Too little water', 'Too big a pot'], right: 0 },
{ ask: 'What do you do with the saucer after watering?', answers: ['Leave it full', 'Empty it after about 20 minutes', 'Take it away'], right: 1 },
]
const question = document.getElementById('question')
const answers = document.getElementById('answers')
const said = document.getElementById('said')
let at = 0
let score = 0
function ask() {
const { ask, answers: choices, right } = questions[at]
question.textContent = `${at + 1} of ${questions.length}. ${ask}`
answers.replaceChildren(...choices.map((text, n) => {
const button = document.createElement('button')
button.textContent = text
button.addEventListener('click', () => answer(n, right))
return button
}))
}
function answer(chosen, right) {
const buttons = [...answers.children]
buttons.forEach((button) => (button.disabled = true))
buttons[right].className = 'right'
if (chosen === right) score += 1
else buttons[chosen].className = 'wrong'
at += 1
const last = at === questions.length
said.textContent = last ? `You got ${score} of ${questions.length}.` : chosen === right ? 'Right.' : 'Not quite.'
const next = document.createElement('button')
next.textContent = last ? 'Start again' : 'Next question'
next.addEventListener('click', () => {
if (last) { at = 0; score = 0 }
said.textContent = ''
ask()
})
answers.append(next)
}
ask()
</script>
An app keeps nothing between runs. Reload the page and the quiz starts over.
A model in 3D, with a library
The last app is a potted Monstera drawn by three.js, a library for 3D in a browser. Drag it round, and try the slider:
The block names the library in a standard import map, near the top:
<script type="importmap">
{ "imports": { "three": "../assets/three-module-min-0-170-0.08fd7545.js" } }
</script>
That address is a file in the graph's own assets folder, next to the pictures. EtherPK never fetches a library when a note opens. If you write a web address there instead, the app doesn't start, and EtherPK shows a Keep a copy button in its place. Press the button and EtherPK fetches the file once, saves the file with your notes, and changes the address to the saved file. From then on the app runs with the copy, with or without a connection.
The line <meta name="etherpk:height" content="480"> gives this app a height, because a canvas that fills its frame has no height of its own to go by.
Here's the whole block. It's longer than the other two, since it builds the pot, the leaves and the light by hand:
<title>Monstera in 3D</title>
<meta name="etherpk:height" content="480">
<script type="importmap">
{ "imports": { "three": "../assets/three-module-min-0-170-0.08fd7545.js" } }
</script>
<style>
html, body { height: 100%; }
body { padding: 0; overflow: hidden; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--app-accent) 16%, var(--app-background)), var(--app-background) 72%); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }
.controls { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 14px; align-items: center; padding: 6px 12px; border: 1px solid var(--app-border); border-radius: 8px; background: var(--app-background); font-size: 14px; }
.controls label { display: flex; gap: 6px; align-items: center; }
</style>
<canvas id="scene" aria-label="A potted Monstera, drawn in three dimensions"></canvas>
<div class="controls">
<label>Leaves <input id="leaves" type="range" min="3" max="14" value="8"></label>
<label><input id="turn" type="checkbox" checked> Turn</label>
</div>
<script type="module">
import * as THREE from 'three'
const canvas = document.getElementById('scene')
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true })
renderer.setPixelRatio(Math.min(devicePixelRatio, 2))
renderer.shadowMap.enabled = true
renderer.shadowMap.type = THREE.PCFSoftShadowMap
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(34, 1, 0.1, 100)
camera.position.set(0, 3.2, 12)
camera.lookAt(0, 2.1, 0)
scene.add(new THREE.HemisphereLight(0xe6f1ff, 0x4a3524, 1.25))
const sun = new THREE.DirectionalLight(0xfff0d2, 2.6)
sun.position.set(4, 9, 5)
sun.castShadow = true
sun.shadow.mapSize.set(1024, 1024)
sun.shadow.normalBias = 0.06
Object.assign(sun.shadow.camera, { left: -5, right: 5, top: 6, bottom: -2 })
scene.add(sun)
// The floor only holds the shadow, so the page's own colour shows through.
const floor = new THREE.Mesh(new THREE.CircleGeometry(7, 64), new THREE.ShadowMaterial({ opacity: 0.22 }))
floor.rotation.x = -Math.PI / 2
floor.receiveShadow = true
scene.add(floor)
const plant = new THREE.Group()
scene.add(plant)
const clay = new THREE.MeshStandardMaterial({ color: 0xb8643d, roughness: 0.85, side: THREE.DoubleSide })
const pot = new THREE.Mesh(new THREE.CylinderGeometry(1.15, 0.8, 1.3, 48, 1, true), clay)
pot.position.y = 0.65
pot.castShadow = true
const rim = new THREE.Mesh(new THREE.TorusGeometry(1.16, 0.075, 12, 48), clay)
rim.rotation.x = Math.PI / 2
rim.position.y = 1.3
rim.castShadow = true
const base = new THREE.Mesh(new THREE.CircleGeometry(0.8, 48), clay)
base.rotation.x = Math.PI / 2
base.position.y = 0.01
const soil = new THREE.Mesh(new THREE.CircleGeometry(1.12, 48), new THREE.MeshStandardMaterial({ color: 0x2c1e15, roughness: 1 }))
soil.rotation.x = -Math.PI / 2
soil.position.y = 1.18
soil.receiveShadow = true
plant.add(pot, rim, base, soil)
// One leaf: a heart with the holes a Monstera is known for, bent along its length and cupped.
const outline = new THREE.Shape()
outline.moveTo(0, 0)
outline.bezierCurveTo(0.95, 0.05, 1.15, 1.25, 0, 2.05)
outline.bezierCurveTo(-1.15, 1.25, -0.95, 0.05, 0, 0)
for (const [x, y, rx, ry, turn] of [[0.4, 0.72, 0.11, 0.27, -0.55], [-0.4, 0.72, 0.11, 0.27, 0.55], [0.33, 1.22, 0.085, 0.21, -0.75], [-0.33, 1.22, 0.085, 0.21, 0.75]]) {
const hole = new THREE.Path()
hole.absellipse(x, y, rx, ry, 0, Math.PI * 2, false, turn)
outline.holes.push(hole)
}
const leafShape = new THREE.ShapeGeometry(outline, 28)
const at = leafShape.attributes.position
for (let i = 0; i < at.count; i++) at.setZ(i, 0.24 * at.getX(i) ** 2 - 0.09 * at.getY(i) ** 2)
leafShape.computeVertexNormals()
const stemColour = new THREE.MeshStandardMaterial({ color: 0x3f7d3a, roughness: 0.7 })
const leaves = new THREE.Group()
plant.add(leaves)
let holders = []
function grow(count) {
for (const child of [...leaves.children]) {
leaves.remove(child)
if (child.geometry !== leafShape) child.geometry?.dispose()
}
holders = []
for (let i = 0; i < count; i++) {
const along = (i + 0.5) / count
const angle = i * 2.39996
const reach = 0.8 + 1.55 * along
const from = new THREE.Vector3(Math.cos(angle) * 0.22, 1.18, Math.sin(angle) * 0.22)
const to = new THREE.Vector3(Math.cos(angle) * reach, 4.0 - 2.0 * along + (i % 2) * 0.22, Math.sin(angle) * reach)
const bend = from.clone().lerp(to, 0.55)
bend.y += 0.95
bend.x *= 0.5
bend.z *= 0.5
const stem = new THREE.Mesh(new THREE.TubeGeometry(new THREE.CatmullRomCurve3([from, bend, to]), 24, 0.036, 8), stemColour)
stem.castShadow = true
const colour = new THREE.Color().setHSL(0.33 + 0.03 * Math.sin(i * 1.7), 0.5, 0.25 + 0.08 * along)
const leaf = new THREE.Mesh(leafShape, new THREE.MeshStandardMaterial({ color: colour, roughness: 0.5, side: THREE.DoubleSide }))
leaf.scale.setScalar(0.55 + 0.5 * along)
leaf.castShadow = true
leaf.receiveShadow = true
// The leaf lies flat with its tip away from the pot, then droops.
const holder = new THREE.Group()
holder.position.copy(to)
holder.rotation.order = 'YXZ'
holder.rotation.y = -Math.PI / 2 - angle
holder.userData = { droop: -Math.PI / 2 - 0.3 - 0.45 * along, beat: i * 1.3 }
holder.add(leaf)
leaves.add(stem, holder)
holders.push(holder)
}
}
// Dust in the light, for no reason but that it looks nice.
const dust = new Float32Array(240 * 3)
for (let i = 0; i < dust.length; i += 3) {
const radius = 2 + Math.random() * 3.5
const angle = Math.random() * Math.PI * 2
dust.set([Math.cos(angle) * radius, 0.6 + Math.random() * 5, Math.sin(angle) * radius], i)
}
const motes = new THREE.Points(new THREE.BufferGeometry().setAttribute('position', new THREE.BufferAttribute(dust, 3)), new THREE.PointsMaterial({ color: 0xffe2a8, size: 0.045, transparent: true, opacity: 0.8 }))
scene.add(motes)
const count = document.getElementById('leaves')
const turn = document.getElementById('turn')
count.addEventListener('input', () => grow(Number(count.value)))
grow(Number(count.value))
let dragging = null
canvas.addEventListener('pointerdown', (event) => {
dragging = event.clientX
canvas.setPointerCapture(event.pointerId)
})
canvas.addEventListener('pointermove', (event) => {
if (dragging === null) return
plant.rotation.y += (event.clientX - dragging) * 0.01
dragging = event.clientX
})
canvas.addEventListener('pointerup', () => (dragging = null))
canvas.addEventListener('pointercancel', () => (dragging = null))
new ResizeObserver(() => {
const width = canvas.clientWidth
const height = canvas.clientHeight
if (width === 0 || height === 0) return
renderer.setSize(width, height, false)
camera.aspect = width / height
camera.updateProjectionMatrix()
}).observe(canvas)
const still = matchMedia('(prefers-reduced-motion: reduce)').matches
renderer.setAnimationLoop((time) => {
const seconds = time / 1000
if (turn.checked && dragging === null && !still) plant.rotation.y += 0.004
for (const holder of holders) holder.rotation.x = holder.userData.droop + (still ? 0 : Math.sin(seconds * 1.1 + holder.userData.beat) * 0.045)
motes.rotation.y = still ? 0 : seconds * 0.03
renderer.render(scene, camera)
})
</script>
What an app can and can't reach
An app is code, and it may be code you didn't read line by line, written by an agent or by somebody you share a graph with. So the app runs in a frame of its own, and the frame is closed.
- It can't read your notes. Nothing inside the frame can reach the page outside. An app can't see the document it sits in, any other document, your keys or your account. EtherPK hands the app three things: its own code, its libraries and the five colours.
- It can't use the network. An app can't fetch anything, load a picture or a script from an address, or open a connection. That's why a library has to be a copy in the graph.
- It can't keep anything. There's no storage in the frame, so an app can't leave anything on your device, and it can't open a window or download a file.
- It can't pose as EtherPK. An app can draw whatever it likes inside its frame, but the bar above the frame is EtherPK's, and EtherPK never asks for a password inside a note.
In a graph you share with other people, an app that someone else might have written doesn't start by itself. EtherPK shows a Run button where the app would be, so you can look at the code first. Once you've run that exact code on a device, EtherPK starts it for you there from then on, and asks again if anyone changes the code.
An app doesn't run at all in a protected document, which shows the block as code.
On a published page, like this one, each app sits in the same kind of frame, with its libraries written into the page. The app can't read the page outside its frame or anything the site keeps in your browser. A published page is a plain file with no server behind it to set rules, so one thing differs from EtherPK itself: an app there can point its own frame at another address. Treat an app you publish the way you'd treat any script on your site.
Ask an agent for one
A coding agent that works in your notes can write an app into a page as it writes a paragraph: "add a quiz on this chapter", "chart these readings", "draw this as a diagram I can step through".
An agent knows the block exists the same way it knows the rest of the format. In a folder graph, the AGENTS.md that EtherPK writes into the folder describes the block. For a synced graph, the Headless Client tells the agent when it connects. The docs on using AI agents with your notes cover both.
The frame is closed whoever wrote the app, so an agent's app gets no more reach than one of your own.
Still plain Markdown
An app is text in the file and nothing else. It syncs, merges, exports and backs up with the note it's in. Any other Markdown editor shows the block as code, and the app block is part of the EtherPK Format, which The EtherPK Format A Notes Folder For You And Your Agents introduces.
Try it
The demo graph has a page called Interactive Apps with the Monstera and the calculator. Click Edit code on either, change a number, and click away.
The interactive apps docs have the details: what a block can hold, how libraries work, and what you see when an app doesn't run. The EtherPK Format specification has the section a program needs.