Skip to content

Commit 0537f23

Browse files
committed
initial commit (nuxt mongo powersync)
0 parents  commit 0537f23

File tree

15 files changed

+7050
-0
lines changed

15 files changed

+7050
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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
25+
26+
.env.local

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"arrowParens": "always",
4+
"singleQuote": true,
5+
"printWidth": 200
6+
}
7+

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.

app.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<NuxtPage />
3+
</template>
4+
5+
<script setup lang="ts"></script>

nuxt.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import wasm from 'vite-plugin-wasm'
2+
import topLevelAwait from 'vite-plugin-top-level-await'
3+
4+
export default defineNuxtConfig({
5+
compatibilityDate: '2024-07-08',
6+
ssr: false,
7+
spaLoadingTemplate: false,
8+
devtools: { enabled: false },
9+
vite: {
10+
plugins: [topLevelAwait()],
11+
optimizeDeps: {
12+
exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
13+
include: ['@powersync/web > js-logger'], // <-- Include `js-logger` when it isn't installed and imported.
14+
},
15+
worker: {
16+
format: 'es',
17+
plugins: () => [wasm(), topLevelAwait()],
18+
},
19+
},
20+
})

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nuxt-app",
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+
"@powersync/vue": "^0.2.2",
14+
"@powersync/web": "^1.9.0",
15+
"nuxt": "^3.13.2",
16+
"vue": "latest",
17+
"vue-router": "latest"
18+
},
19+
"devDependencies": {
20+
"vite-plugin-top-level-await": "^1.4.4",
21+
"vite-plugin-wasm": "^3.3.0"
22+
}
23+
}

pages/index.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<main>
3+
<h1>LISTS</h1>
4+
5+
<div v-if="isLoading">Loading...</div>
6+
<div v-else-if="isFetching">Updating results...</div>
7+
8+
<div v-if="error">{{ error }}</div>
9+
<ul v-else>
10+
<li v-for="l in list" :key="l.id">{{ l.name }}</li>
11+
</ul>
12+
</main>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import { useQuery } from '@powersync/vue'
17+
18+
const query = ref('SELECT * from lists')
19+
const { data: list, isLoading, isFetching, error } = useQuery(query, [], {})
20+
</script>

plugins/usePowersync.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { PowerSyncDatabase } from '@powersync/web'
2+
import { createPowerSyncPlugin } from '@powersync/vue'
3+
import { Connector } from '~/powersync/Connector'
4+
import { AppSchema } from '~/powersync/AppSchema'
5+
6+
export default defineNuxtPlugin((nuxtApp) => {
7+
const db = new PowerSyncDatabase({
8+
schema: AppSchema,
9+
database: {
10+
dbFilename: 'powersync.db',
11+
},
12+
})
13+
14+
const connector = new Connector()
15+
db.connect(connector)
16+
17+
nuxtApp.vueApp.use(createPowerSyncPlugin({ database: db }))
18+
})

0 commit comments

Comments
 (0)