How-to
Recipes
Each recipe is one task: the complete code first, then how it works. Every wf example on these pages parses and type-checks in the test suite; a recipe that needs more than its page — a setting in webfluent.app.json, a picture, a data file, a script, another recipe — says so in a Needs: line above the code. To try one, paste the page into a new file under src/pages/ of a project. Most claim the address / or a name the wf init starter already has (Home, Tasks, Settings, User), so start a new project for it (wf init try-it), or replace the starter's file of that name (src/pages/Home.wf for /).
Interaction
Lists, dialogs, filters, the address bar and the keyboard: what a page does when the reader acts.
Keep the active tab in the address
Website
Web app
Keep filters in the address
Website
Web app
Build a confirm dialog
Website
Web app
Copy to the clipboard
Website
Web app
Debounce a search
Website
Web app
Count down
Website
Web app
Make navigation responsive
Website
Web app
Pass a store's value to a component
Website
Web app
Reorder a list by dragging
Website
Web app
Desktop / phone
Add keyboard shortcuts and a command palette
Website
Web app
Desktop / phone
Make a page work with a keyboard and a screen reader
Website
Web app
Forms and data
Forms, asking a server, showing what it answers, and writing back.
Show validation messages on a form
Website
Web app
Sign in with a session cookie
Website
Web app
Page through results
Website
Web app
Load more as the reader asks
Website
Web app
Update at once, and roll back on failure
Website
Web app
Show the server's field errors on a form
Website
Web app
Refresh a list after a write
Website
Web app
Call a service from its OpenAPI spec
Website
Web app
Show what the network is doing
Website
Web app
Desktop / phone
Send a message as the page unloads
Website
Web app
Real time
Sockets, streams, other tabs, other readers and workers.
Content
Markdown, pages written as Markdown, HTML from elsewhere, code on the page, a page per item, a page for unknown addresses, a PDF, and what search engines and link previews read.
Write a page as a Markdown file
Website
Web app
Render Markdown
Website
Web app
Slides
Custom elements
Desktop / phone
Show HTML from outside the project
Website
Web app
Show code on a page
Website
Web app
Slides
Custom elements
Desktop / phone
Describe pages to search engines and link previews
Website
Pre-render a page for each item
Website
Show your own page for an unknown address
Website
Web app
Make a PDF report
Media and themes
Pictures, video, icons, a carousel, other pages in a frame, and a dark theme.
Motion
Animation, from one element appearing to a page carried into the next. Read them in order: each builds on the one before.
Animate an element in and out
Website
Web app
Animate a list
Website
Web app
Run a sequence of animations
Website
Web app
Animate route changes
Website
Web app
Carry an element across a route change
Website
Web app
Open a box to the height of its content
Website
Web app
Count a number to its new value
Website
Web app
Tween a property when state changes
Website
Web app
Declare your own keyframes
Website
Web app
Drive an animation yourself
Website
Web app
Set motion defaults, and respect reduced motion
Website
Web app
Reach
More readers: other languages, and no network.
Testing
Checking that a page does what it should before a reader finds out it does not.
Ship
Putting a site on a host, in the order you need them: install `wf` where the site is built, set what changes per environment, deploy to a host or serve from your own server, then check the deploy.
Install wf on a build machine
Website
Web app
Use environment values, and keep secrets out
Website
Web app
Desktop / phone
Deploy to GitHub Pages
Website
Web app
Deploy to Netlify
Website
Web app
Deploy to Vercel
Website
Web app
Deploy to Cloudflare Pages
Website
Web app
Build a Docker image
Website
Web app
Serve a site with nginx
Website
Web app
Serve a site with Apache
Website
Web app
Serve a site with Caddy
Website
Web app
Serve an API on the same origin
Website
Web app
Set cache and security headers
Website
Web app
Allow other origins in the security policy
Website
Web app
Review a site's security before you deploy
Website
Web app
Check a deploy
Website
Web app
Desktop and phone apps
The same project in a window of its own, with Tauri or Electron.
Interop
Your own JavaScript, libraries, and custom elements, both ways.
Call your own JavaScript
Website
Web app
Desktop / phone
Call WF from a script
Website
Web app
Desktop / phone
Hand an element to a script
Website
Web app
Desktop / phone
Run a script after each page draws
Website
Web app
Draw into a node a script made
Website
Web app
Desktop / phone
Load a library from a CDN
Website
Web app
Draw a chart from a library
Website
Web app
Place a custom element from a library
Website
Web app
Publish components as custom elements
Custom elements
Upgrade a WebFluent 4 project that uses external
Website
Web app
Server rendering
WebFluent as a template engine: HTML and PDF from data, from the command line, Node or Rust.
Projects
Two complete projects, explained step by step. They are read along in the finished code under `examples/tutorials/`, not typed along; each says how to build it yourself if you want to.