How a tik works
Where a tik runs, what it can reach, the libraries it gets for free, and what happens when you publish.
Where it runs
A tik runs in a WebView inside the Codetik app on iOS and Android, and on the web from a link. One publish covers all three.
- Portrait, full screen, touch. Design for a 390×844 viewport at a pixel ratio of 2 to 3. There is no keyboard, mouse or hover. Tap targets are at least 44 px.
- Offline. A tik has no network. Every script, image, sound and font ships with it; nothing is loaded from a URL.
- Sandboxed. Each tik has its own origin.
localStorageand IndexedDB work and stay on the device, apart from every other tik. - The app owns the edges. The notch and the home indicator sit outside the WebView, so
env(safe-area-inset-*)reads 0. Use plain padding,height: 100%on the top frame, and never100dvhor100svh.
The folder
snake/├─ index.html # entry; index2.html, index3.html for multi-screen tiks├─ src/main.ts # TypeScript entry├─ src/tik.d.ts # window.tik types, generated by the CLI├─ public/ # assets, served from the root├─ backend/src/ # optional realtime backend├─ package.json # peerDependencies = the libraries you use├─ tsconfig.json├─ tik.yaml # title, category, tags, permissions; never shipped├─ tik.webp # 512×512 logo; never shipped└─ AGENTS.md # the brief for whoever edits it nextWhat ships is an allowlist: root *.html, package.json, tsconfig.json, tik.config.json, text files under src/, text and media under public/, and backend/src/**.ts. Dotfiles, scripts/, node_modules/, dist/ and docs never ship.
No build config of your own. Codetik builds every tik with the same Vite and TypeScript setup, so a vite.config or postcss config is not used. A tik folder is self-contained: no ../ imports.
Lifecycle
The feed loads tiks before anyone scrolls to them. A tik starts when it becomes visible and pauses everything when it leaves: loops, timers, audio and backend traffic. An off-screen tik that keeps running burns battery, and its intro is over before anyone sees it.
let frame = 0;let running = false; function start(): void { if (running) return; running = true; frame = requestAnimationFrame(loop);} function stop(): void { running = false; cancelAnimationFrame(frame);} function loop(): void { if (!running) return; draw(); frame = requestAnimationFrame(loop);} // Read visible() and subscribe: events fire only on change.if (tik.visible()) start();tik.on('visible', start);tik.on('hidden', stop);window.tik
window.tik is injected before any of your scripts run: no import, no existence check. Its types are in src/tik.d.ts.
| Member | What it gives | Present |
|---|---|---|
visible(), on, off | Whether the tik is on screen, and its changes | Always |
profile() | The viewer's username and avatar, for display | With profile |
token() | The viewer's identity, for the backend | With auth |
users.search() | Find users by username | With token() |
spacetimedb() | The URL and name of the tik's realtime database | With a backend |
openrouter, google | The viewer's own OpenRouter account or Google Drive | When declared |
An accessor exists only when its permission is granted, so if (tik.profile) is the feature test. Locale and time come from the standard web APIs.
Libraries and fonts
Popular libraries ship inside the Codetik app, so they are already on every user's phone. Add one with codetik add <name>, which names it in package.json peerDependencies, and the import resolves to that copy: nothing is bundled, nothing is installed into the tik and nothing is downloaded when it opens. A tik stays small, loads in the background before anyone scrolls to it and starts instantly. A name outside the list fails the build.
"peerDependencies": { "phaser": "3.90.0" }| Use | Libraries |
|---|---|
| Game engines | phaser (3), pixi.js (8), @pixi/ui, pixi-filters, three, @react-three/fiber, @react-three/drei, postprocessing, playcanvas |
| Physics | matter-js, cannon-es |
| Audio | howler, tone, tonal |
| Animation and input | animejs, motion, @react-spring/web, canvas-confetti, @use-gesture/vanilla, @use-gesture/react, interactjs |
| Generative and data | simplex-noise, pts, roughjs, chroma-js, d3, chart.js, echarts |
| UI | react (18), react-dom, marked |
| Multiplayer | spacetimedb |
| AI | ai, @openrouter/ai-sdk-provider (the viewer's own OpenRouter account) |
codetik manifest prints the live list with each pinned version. React is for tiks whose surface is DOM (forms, lists, panels); a game you draw yourself is plain TypeScript on a canvas, or PixiJS, or Phaser when it wants a full engine.
Shared fonts load from /shared-libs/fonts/<slug>/<weight>.woff2, among them pixel faces like Press Start 2P, VT323 and Silkscreen, and Inter, JetBrains Mono and Space Grotesk for UI. Your own .woff2 in public/ works too.
Permissions
Nothing is granted by default. You can turn on four things yourself with codetik permissions; the app enforces them, not the tik.
| Grant | What the tik gets | Set with |
|---|---|---|
profile | tik.profile(): the viewer's name and avatar | codetik permissions --profile on |
| A backend | A realtime database, with anonymous users | codetik backend |
auth | A backend that knows who is playing, through tik.token() | codetik backend, then codetik permissions --auth on |
| Microphone | Audio input, after the app asks the viewer | codetik permissions --mic on |
Links to well-known sites (YouTube, GitHub and others) can open over the tik with codetik permissions --links. Network access and anything else that reaches outside the sandbox is granted by Codetik only; a publish that asks for it is refused.
Backend
A backend is a SpacetimeDB module in backend/src/, written in TypeScript: tables plus the functions that change them. The tik talks to it over a WebSocket and every user sees every change live, which is what scores, rooms, presence and turn-based games are built on.
codetik backendturns it on and publishes the module.codetik devrepublishes it on every save. You never install the SpacetimeDB CLI.- One database per tik, shared by development and the published tik.
- A breaking schema change is refused, before release too. After release the data belongs to the users: a breaking change is refused unless you reset the database on purpose.
- A backend needs the Pro plan.
Limits
| Limit | |
|---|---|
| Source | 20 MB, 500 files |
| One file | 512 KB |
| Upload (source, logo, video) | 24 MB |
Logo tik.webp | 512×512, square, under 256 KB; needed to go live |
| Promo video | Optional, up to 2 MB: h264 tik-video.mp4 or animated webp |
| Images | Warning above 400 KB (512 KB for a sprite sheet) |
| Audio | Warning above 1 MB; 24 kbps stereo mp3 at 22.05 kHz is plenty |
| Slides | Up to 10 screens |
| Title, description, tags | 40 characters, 300 characters, 6 tags |
Publishing
codetik publishpushes a draft: Codetik builds it, nobody else sees it, and it shows under Drafts in your app for testing on a phone.codetik publish --livereleases it at thevisibilityintik.yaml:public(the feed),unlisted(on your profile and by link) orprivate(only you). A release needs a logo and a category.- Every release goes through a check. Codetik's agent removes unused files and fixes build and type errors, and the CLI asks before writing those edits back into your folder. If you leave them out of
tik.yaml, Codetik also writes the description, tags and the fork suggestions. - A public tik cannot be republished, changed or deleted from the CLI. Private and unlisted tiks can be republished freely.
- After release,
codetik issueslists the bugs and performance problems users hit, with the file and function they came from.