Skip to content

Commit bdfcbe3

Browse files
committed
feat: add minimal Nuxt example with nuxt-query
1 parent 4f4e202 commit bdfcbe3

File tree

10 files changed

+222
-0
lines changed

10 files changed

+222
-0
lines changed

examples/minimal/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example

examples/minimal/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Nuxt Minimal Starter
2+
3+
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4+
5+
## Setup
6+
7+
Make sure to install dependencies:
8+
9+
```bash
10+
# npm
11+
npm install
12+
13+
# pnpm
14+
pnpm install
15+
16+
# yarn
17+
yarn install
18+
19+
# bun
20+
bun install
21+
```
22+
23+
## Development Server
24+
25+
Start the development server on `http://localhost:3000`:
26+
27+
```bash
28+
# npm
29+
npm run dev
30+
31+
# pnpm
32+
pnpm dev
33+
34+
# yarn
35+
yarn dev
36+
37+
# bun
38+
bun run dev
39+
```
40+
41+
## Production
42+
43+
Build the application for production:
44+
45+
```bash
46+
# npm
47+
npm run build
48+
49+
# pnpm
50+
pnpm build
51+
52+
# yarn
53+
yarn build
54+
55+
# bun
56+
bun run build
57+
```
58+
59+
Locally preview production build:
60+
61+
```bash
62+
# npm
63+
npm run preview
64+
65+
# pnpm
66+
pnpm preview
67+
68+
# yarn
69+
yarn preview
70+
71+
# bun
72+
bun run preview
73+
```
74+
75+
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

examples/minimal/app.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script lang="ts" setup>
2+
const getUsers = async () => {
3+
return await $fetch('https://jsonplaceholder.typicode.com/users')
4+
}
5+
6+
const { isPending: isPending, data: users } = useQuery({
7+
queryKey: ['users'],
8+
queryFn: getUsers,
9+
})
10+
</script>
11+
12+
<template>
13+
<h1>Users</h1>
14+
<div v-if="isPending">
15+
Loading...
16+
</div>
17+
<div
18+
v-else
19+
:style="{
20+
display: 'grid',
21+
gap: '0.5rem',
22+
paddingLeft: '0.5rem',
23+
}"
24+
>
25+
<div
26+
v-for="user in users"
27+
:key="user.id"
28+
:style="{
29+
cursor: 'pointer',
30+
paddingTop: '0.25rem',
31+
borderRadius: '0.125rem',
32+
}"
33+
>
34+
{{ user.name }} ({{ user.email }})
35+
</div>
36+
</div>
37+
</template>

examples/minimal/nuxt.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
modules: ['@peterbud/nuxt-query'],
4+
devtools: { enabled: true },
5+
compatibilityDate: '2024-11-01',
6+
nuxtQuery: {
7+
autoImports: ['useQuery', 'useMutation', 'useQueryClient'],
8+
},
9+
})

examples/minimal/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "nuxt-query-minimal-example",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"postinstall": "nuxt prepare"
11+
},
12+
"dependencies": {
13+
"@peterbud/nuxt-query": "^0.0.5",
14+
"nuxt": "^3.16.0",
15+
"vue": "^3.5.13",
16+
"vue-router": "^4.5.0"
17+
}
18+
}
4.19 KB
Binary file not shown.

examples/minimal/public/robots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../.nuxt/tsconfig.server.json"
3+
}

examples/minimal/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// https://nuxt.com/docs/guide/concepts/typescript
3+
"extends": "./.nuxt/tsconfig.json"
4+
}

pnpm-lock.yaml

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)