Bynk by Example
Bynk by Example is a problem-first tour of the language: each page starts with a thing you want to do and shows the real code that does it. It comes in two tiers — snippets, single-file language primitives you can open and type-check in the browser playground, and projects, complete example apps that each compile to a deployable Cloudflare Worker. Read them in any order; every example type-checks as shown.
Snippets
Section titled “Snippets”Refined typesConstrain a type once; every value that exists has passed the check.
Sum types and matchOne of several named shapes, handled exhaustively or the compiler rejects it.
is-narrowingTest a value against a pattern and narrow it without an explicit unwrap.
Result and OptionErrors and absence are values; no null, no thrown exceptions.
Opaque typesA distinct type backed by another, so the two can never be mixed up.
Validate and transformValidate input with .of, then unwrap-or-return-early with ?.
Projects
Section titled “Projects”Greet a visitorA greeter: refined types, a capability, typed HTTP, and a test.
Shorten a URLMint short codes and resolve them, backed by KV with a TTL.
Toggle a feature flagPublic and authorised routes over a KV-backed flag store.
Keep a per-user todo listA per-caller agent holding a storage Map queried with Query[T].
Join orders and line itemsStorage Maps with @indexed and Query[T] joins, groups, and aggregates.
Expire sessions with a CacheA Cache with per-entry @ttl expiry on the platform clock.
Append to a retained event logA Log with @retain and time-window queries over events.
Rate-limit per clientOne Durable Object per key enforcing a fixed-window policy.
Probe URLs on a scheduleScheduled checks that call the outside world and record results.
Verify a signed webhookVerify a signed webhook, then forward it on.