Preact + preact-iso
The Preact team's lightweight router; works with plain <a> links. This page shows exactly what pickstack adds to a Preact project for preact-iso: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.
$ npm create pickstack@latest my-app -- --framework preact --modules preact-iso --yesCustomize in the configurator
Packages it adds
| Package | Version | Type |
|---|---|---|
preact-iso | ^2.12.2 | runtime |
preact-render-to-string | ^6.8.3 | runtime |
New files
export default function About() {
return (
<section class="page">
<h1 class="title">About</h1>
<p class="text">Built with Preact, Vite, TypeScript, preact-iso.</p>
</section>
);
}
import Counter from "../components/Counter";
export default function Home() {
return (
<section class="page">
<h1 class="title">my-app</h1>
<Counter />
</section>
);
}
Changes to existing files
+import { Route, Router } from "preact-iso";+import About from "./pages/About";+import Home from "./pages/Home";−import Counter from "./components/Counter"; export default function App() { return ( <main class="app">+ <nav class="nav">+ <a class="link" href="/">+ Home+ </a>+ <a class="link" href="/about">+ About+ </a>+ </nav>+ <Router>+ <Route path="/" component={Home} />+ <Route path="/about" component={About} />+ </Router>− <h1 class="title">my-app</h1>− <Counter /> </main> ); }⋯ 1 unchanged lines
import { render } from "preact";+import { LocationProvider } from "preact-iso"; import App from "./App"; import "./index.css"; +render(+ <LocationProvider>+ <App />+ </LocationProvider>,+ document.getElementById("app")!,+);−render(<App />, document.getElementById("app")!);
Project files
.gitignoreREADME.mdindex.htmlpackage.jsonsrc/App.tsxsrc/components/Counter.tsxsrc/index.csssrc/main.tsxsrc/pages/About.tsxsrc/pages/Home.tsxtsconfig.app.jsontsconfig.jsontsconfig.node.jsonvite.config.ts