Docs›Get started

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. localStorage and 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 never 100dvh or 100svh.

The folder

snake/Text
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 next

What 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.

TypeScript
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.

MemberWhat it givesPresent
visible(), on, offWhether the tik is on screen, and its changesAlways
profile()The viewer's username and avatar, for displayWith profile
token()The viewer's identity, for the backendWith auth
users.search()Find users by usernameWith token()
spacetimedb()The URL and name of the tik's realtime databaseWith a backend
openrouter, googleThe viewer's own OpenRouter account or Google DriveWhen 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.

package.jsonjson
"peerDependencies": { "phaser": "3.90.0" }
UseLibraries
Game enginesphaser (3), pixi.js (8), @pixi/ui, pixi-filters, three, @react-three/fiber, @react-three/drei, postprocessing, playcanvas
Physicsmatter-js, cannon-es
Audiohowler, tone, tonal
Animation and inputanimejs, motion, @react-spring/web, canvas-confetti, @use-gesture/vanilla, @use-gesture/react, interactjs
Generative and datasimplex-noise, pts, roughjs, chroma-js, d3, chart.js, echarts
UIreact (18), react-dom, marked
Multiplayerspacetimedb
AIai, @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.

GrantWhat the tik getsSet with
profiletik.profile(): the viewer's name and avatarcodetik permissions --profile on
A backendA realtime database, with anonymous userscodetik backend
authA backend that knows who is playing, through tik.token()codetik backend, then codetik permissions --auth on
MicrophoneAudio input, after the app asks the viewercodetik 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 backend turns it on and publishes the module. codetik dev republishes 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
Source20 MB, 500 files
One file512 KB
Upload (source, logo, video)24 MB
Logo tik.webp512×512, square, under 256 KB; needed to go live
Promo videoOptional, up to 2 MB: h264 tik-video.mp4 or animated webp
ImagesWarning above 400 KB (512 KB for a sprite sheet)
AudioWarning above 1 MB; 24 kbps stereo mp3 at 22.05 kHz is plenty
SlidesUp to 10 screens
Title, description, tags40 characters, 300 characters, 6 tags

Publishing

  • codetik publish pushes a draft: Codetik builds it, nobody else sees it, and it shows under Drafts in your app for testing on a phone.
  • codetik publish --live releases it at the visibility in tik.yaml: public (the feed), unlisted (on your profile and by link) or private (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 issues lists the bugs and performance problems users hit, with the file and function they came from.