Vue + Pinia starter
Vite, Vue Router, Pinia, TanStack Query, Tailwind. A tested combination you can create in one command and keep extending.
$ npm create pickstack@latest my-app -- --framework vue --modules tailwind,pinia,vue-router,tanstack-query,vitest,testing-library,eslint,prettier --yesCustomize in the configurator
Packages
| Package | Version | Type |
|---|---|---|
@tanstack/vue-query | ^5.108.4 | runtime |
@vue/devtools-api | ^8.2.1 | runtime |
pinia | ^4.1.0 | runtime |
vue-router | ^5.5.1 | runtime |
@tailwindcss/vite | ^4.3.5 | dev |
@testing-library/dom | ^10.4.2 | dev |
@testing-library/jest-dom | ^8.0.0 | dev |
@testing-library/user-event | ^14.6.13 | dev |
@testing-library/vue | ^8.1.0 | dev |
@types/jsdom | ^30.0.0 | dev |
@vue/eslint-config-typescript | ^14.9.0 | dev |
@vue/test-utils | ^2.6.0 | dev |
eslint | ^10.15.0 | dev |
eslint-config-prettier | ^10.1.8 | dev |
eslint-plugin-vue | ^10.12.1 | dev |
jiti | ^2.7.0 | dev |
jsdom | ^31.0.1 | dev |
prettier | ^3.10.1 | dev |
tailwindcss | ^4.3.5 | dev |
vitest | ^5.1.1 | dev |
vue-eslint-parser | ^10.4.2 | dev |
New files
dist pnpm-lock.yaml package-lock.json yarn.lock bun.lock
{}
import { globalIgnores } from "eslint/config";
import {
defineConfigWithVueTs,
vueTsConfigs,
} from "@vue/eslint-config-typescript";
import pluginVue from "eslint-plugin-vue";
import skipFormatting from "eslint-config-prettier/flat";
export default defineConfigWithVueTs(
{
name: "app/files-to-lint",
files: ["**/*.{vue,ts,mts,tsx}"],
},
globalIgnores(["**/dist/**", "**/dist-ssr/**", "**/coverage/**"]),
...pluginVue.configs["flat/essential"],
vueTsConfigs.recommended,
skipFormatting,
);
[
"Vue 3",
"Vite",
"TypeScript",
"Tailwind CSS",
"Pinia",
"Vue Router",
"TanStack Query",
"Vitest",
"Testing Library",
"ESLint",
"Prettier"
]
/** Loads the stack list served from `public/stack.json`. */
export async function fetchStack(): Promise<string[]> {
const response = await fetch(`${import.meta.env.BASE_URL}stack.json`);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
return response.json();
}
import userEvent from "@testing-library/user-event";
import { render, screen } from "@testing-library/vue";
import { createPinia } from "pinia";
import { describe, expect, it } from "vitest";
import CounterCard from "../CounterCard.vue";
describe("CounterCard", () => {
it("increments when +1 is clicked", async () => {
const user = userEvent.setup();
render(CounterCard, { global: { plugins: [createPinia()] } });
await user.click(screen.getByRole("button", { name: "+1" }));
expect(screen.getByText("1")).toBeInTheDocument();
});
});
<script setup lang="ts">
import { useQuery } from "@tanstack/vue-query";
import { fetchStack } from "../api/stack";
const { isPending, isError, data } = useQuery({
queryKey: ["stack"],
queryFn: fetchStack,
});
</script>
<template>
<p v-if="isPending" class="max-w-md text-center text-slate-600">Loading…</p>
<p v-else-if="isError" class="max-w-md text-center text-slate-600">
Could not load the stack.
</p>
<p v-else class="max-w-md text-center text-slate-600">
Built with {{ data?.join(", ") }}.
</p>
</template>
import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "home",
component: HomeView,
},
{
path: "/about",
name: "about",
component: () => import("../views/AboutView.vue"),
},
],
});
export default router;
import { defineStore } from "pinia";
import { ref } from "vue";
export const useCounterStore = defineStore("counter", () => {
const count = ref(0);
function increment() {
count.value++;
}
function decrement() {
count.value--;
}
return { count, increment, decrement };
});
import "@testing-library/jest-dom/vitest";
import { cleanup } from "@testing-library/vue";
import { afterEach } from "vitest";
afterEach(() => {
cleanup();
});
<template>
<section class="flex flex-col items-center gap-6">
<h1 class="text-3xl font-bold tracking-tight">About</h1>
<p class="max-w-md text-center text-slate-600">
Built with Vue 3, Vite, TypeScript, Tailwind CSS, Pinia, Vue Router,
TanStack Query, Vitest, Testing Library, ESLint, Prettier.
</p>
</section>
</template>
<script setup lang="ts">
import CounterCard from "../components/CounterCard.vue";
import StackList from "../components/StackList.vue";
</script>
<template>
<section class="flex flex-col items-center gap-6">
<h1 class="text-3xl font-bold tracking-tight">my-app</h1>
<CounterCard />
<StackList />
</section>
</template>
{
"extends": "./tsconfig.app.json",
"include": ["src/**/__tests__/*", "src/test-setup.ts", "env.d.ts"],
"exclude": [],
"compilerOptions": {
"lib": [],
"types": ["node", "jsdom"],
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo"
}
}
import { fileURLToPath } from "node:url";
import { defineConfig, mergeConfig } from "vitest/config";
import viteConfig from "./vite.config.ts";
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: "jsdom",
setupFiles: ["./src/test-setup.ts"],
root: fileURLToPath(new URL("./", import.meta.url)),
},
}),
);
Changes to existing files
<script setup lang="ts">+import { RouterLink, RouterView } from "vue-router";−import CounterCard from "./components/CounterCard.vue"; </script> <template>+ <main+ class="flex min-h-screen flex-col items-center justify-center gap-8 bg-slate-50 p-8 text-slate-900"+ >+ <nav class="flex gap-4 text-sm font-medium">+ <RouterLink class="text-slate-600 hover:text-slate-900" to="/">+ Home+ </RouterLink>+ <RouterLink class="text-slate-600 hover:text-slate-900" to="/about">+ About+ </RouterLink>+ </nav>+ <RouterView />− <main class="app">− <h1 class="title">my-app</h1>− <CounterCard /> </main> </template>
+@import "tailwindcss";−:root {− font-family: system-ui, sans-serif;− color: #0f172a;− background: #f8fafc;−} −body {− margin: 0;−}− −.app {− min-height: 100vh;− display: flex;− flex-direction: column;− align-items: center;− justify-content: center;− gap: 2rem;− padding: 2rem;− box-sizing: border-box;−}− −.title {− font-size: 1.875rem;− margin: 0;−}− −.nav {− display: flex;− gap: 1rem;−}− −.link {− color: #475569;− text-decoration: none;− font-weight: 500;−}− −.link:hover {− color: #0f172a;−}− −.page {− display: flex;− flex-direction: column;− align-items: center;− gap: 1.5rem;−}− −.text {− max-width: 28rem;− text-align: center;− color: #475569;−}− −.card {− background: #fff;− padding: 2rem;− border-radius: 1rem;− box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);− text-align: center;−}− −.count {− font-size: 3rem;− font-weight: 700;− margin: 0;− font-variant-numeric: tabular-nums;−}− −.row {− margin-top: 1.5rem;− display: flex;− justify-content: center;− gap: 0.75rem;−}− −.btn {− background: #0f172a;− color: #fff;− border: 0;− border-radius: 0.5rem;− padding: 0.5rem 1rem;− font: inherit;− cursor: pointer;−}− −.btn:hover {− background: #334155;−}−
<script setup lang="ts">+import { useCounterStore } from "@/stores/counter";−import { ref } from "vue"; +const counter = useCounterStore();−const count = ref(0); </script> <template>+ <div+ class="rounded-2xl bg-white p-8 text-center shadow-sm ring-1 ring-slate-200"+ >+ <p class="text-5xl font-bold tabular-nums">{{ counter.count }}</p>+ <div class="mt-6 flex justify-center gap-3">+ <button+ type="button"+ class="rounded-lg bg-slate-900 px-4 py-2 text-white hover:bg-slate-700"+ @click="counter.decrement()"+ >+ -1+ </button>+ <button+ type="button"+ class="rounded-lg bg-slate-900 px-4 py-2 text-white hover:bg-slate-700"+ @click="counter.increment()"+ >+ +1+ </button>− <div class="card">− <p class="count">{{ count }}</p>− <div class="row">− <button type="button" class="btn" @click="count--">-1</button>− <button type="button" class="btn" @click="count++">+1</button> </div> </div> </template>⋯ 1 unchanged lines
+import { VueQueryPlugin } from "@tanstack/vue-query";+import { createPinia } from "pinia"; import { createApp } from "vue"; import App from "./App.vue";+import router from "./router"; import "./assets/main.css"; +const app = createApp(App);+ +app.use(createPinia());+app.use(router);+app.use(VueQueryPlugin);+ +app.mount("#app");−createApp(App).mount("#app");
{ "extends": "@vue/tsconfig/tsconfig.dom.json", "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],+ "exclude": ["src/**/__tests__/*", "src/test-setup.ts"],− "exclude": ["src/**/__tests__/*"], "compilerOptions": { "noUncheckedIndexedAccess": true, "paths": {⋯ 6 unchanged lines
⋯ 5 unchanged lines }, { "path": "./tsconfig.app.json"+ },+ {+ "path": "./tsconfig.vitest.json" } ] }⋯ 1 unchanged lines
import { fileURLToPath, URL } from "node:url";+import tailwindcss from "@tailwindcss/vite"; import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; export default defineConfig({+ plugins: [vue(), tailwindcss()],− plugins: [vue()], resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)),⋯ 4 unchanged lines
Project files
.gitignore.prettierignore.prettierrcREADME.mdenv.d.tseslint.config.tsindex.htmlpackage.jsonpublic/stack.jsonsrc/App.vuesrc/api/stack.tssrc/assets/main.csssrc/components/CounterCard.vuesrc/components/StackList.vuesrc/components/__tests__/CounterCard.spec.tssrc/main.tssrc/router/index.tssrc/stores/counter.tssrc/test-setup.tssrc/views/AboutView.vuesrc/views/HomeView.vuetsconfig.app.jsontsconfig.jsontsconfig.node.jsontsconfig.vitest.jsonvite.config.tsvitest.config.ts