Skip to content
Greg Bowler edited this page Feb 13, 2025 · 9 revisions

Turbo is a minimalist JavaScript library that's shipped by default with WebEngine. Its purpose is to allow developers to build applications that follow basic HTTP principles, but gain the speed and usability of a single page applications (SPA).

To use Turbo, convert a "regular" HTML form into a turbo form by adding the data-turbo attribute:

<form method="post" data-turbo>
	<label>
		<span>Your name</span>
		<input name="name" required />
	</label>
	<label>
		<span>Your email address</span>
		input name="email" type="email" required />
	</label>
	<button name="do" value="submit">Submit</button>
</form>

When the above form submits, because it has been marked with the data-turbo attribute, the default submit behaviour will be suppressed, and a background fetch will be emitted instead. When the fetch completes, the default behaviour is to replace the form with the form's counterpart on the new HTML document (after submitting the page), but other behaviours can be configured.

Clone this wiki locally