pickstack

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 --yes
Customize in the configurator

Packages it adds

PackageVersionType
preact-iso^2.12.2runtime
preact-render-to-string^6.8.3runtime

New files

src/pages/About.tsx
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>
  );
}
src/pages/Home.tsx
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

src/App.tsx (changed)
+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
src/main.tsx (changed)
 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