pickstack

Next.js + Zustand

Minimal hook-based store, no provider needed. This page shows exactly what pickstack adds to a Next.js project for Zustand: 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 next --modules zustand --yes
Customize in the configurator

Packages it adds

PackageVersionType
zustand^5.1.0runtime

New files

store/useCounterStore.ts
import { create } from "zustand";

interface CounterState {
  count: number;
  increment: () => void;
  decrement: () => void;
}

export const useCounterStore = create<CounterState>()((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
}));

Changes to existing files

app/about/page.tsx (changed)
⋯ 2 unchanged lines     <section className="page">       <h1 className="title">About</h1>       <p className="text">+        Built with Next.js (App Router), React 19, TypeScript, Zustand.−        Built with Next.js (App Router), React 19, TypeScript.       </p>     </section>   );⋯ 2 unchanged lines
components/Counter.tsx (changed)
 "use client";  +import { useCounterStore } from "../store/useCounterStore";−import { useState } from "react";   export default function Counter() {+  const count = useCounterStore((state) => state.count);+  const increment = useCounterStore((state) => state.increment);+  const decrement = useCounterStore((state) => state.decrement);−  const [count, setCount] = useState(0);     return (     <div className="card">       <p className="count">{count}</p>       <div className="row">+        <button type="button" className="btn" onClick={decrement}>−        <button−          type="button"−          className="btn"−          onClick={() => setCount((n) => n - 1)}−        >           -1         </button>+        <button type="button" className="btn" onClick={increment}>−        <button−          type="button"−          className="btn"−          onClick={() => setCount((n) => n + 1)}−        >           +1         </button>       </div>⋯ 4 unchanged lines

Project files

Related templates