Back to the blog

Developer

Write Preact with hooks and watch it run.

Write Preact components with JSX and hooks in your browser and see them run as you type. Nothing uploaded, no install; Preact served by KeepSimp.

By 3 min read

A code playground: HTML, CSS and JavaScript editors on the left, the page they make on the right, and its console underneath

Preact gives React's way of writing components in a few kilobytes. The KeepSimp code playground compiles your JSX for Preact on your device and runs it beside the code.

JSX for Preact.

Open the Preact playground and press Start with a counter. The script imports render from preact and useState from preact/hooks; because it imports Preact, its JSX is compiled for Preact's runtime instead of React's.

KeepSimp serves Preact itself, so the page works offline once it has run.

Bigger than one file.

Put each component in a file of its own in Files, such as Header.jsx, and import it with a relative path; every file's JSX is compiled for Preact too. A package.json pins the versions of any other packages you import from esm.sh.

Your code stays on your device.

Everything is compiled and run in your browser. Nothing you write is uploaded and there is no account. Files from other sites that your page asks for (a package, a font, a stylesheet) are fetched by the page from those sites, as any page would.

Further reading

Topics: preact playground · preact online · preact hooks · jsx playground · react alternative

A little less theory. A little more doing.

Try it on your own terms, with a free browser tool.

Try the tool