@powersync/nuxt 0.0.0-dev-20260128023420

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +201 -0
  2. package/README +374 -0
  3. package/dist/module.d.mts +39 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +160 -0
  6. package/dist/runtime/assets/powersync-icon.svg +14 -0
  7. package/dist/runtime/components/BucketsInspectorTab.d.vue.ts +3 -0
  8. package/dist/runtime/components/BucketsInspectorTab.vue +646 -0
  9. package/dist/runtime/components/BucketsInspectorTab.vue.d.ts +3 -0
  10. package/dist/runtime/components/ConfigInspectorTab.d.vue.ts +3 -0
  11. package/dist/runtime/components/ConfigInspectorTab.vue +121 -0
  12. package/dist/runtime/components/ConfigInspectorTab.vue.d.ts +3 -0
  13. package/dist/runtime/components/DataInspectorTab.d.vue.ts +3 -0
  14. package/dist/runtime/components/DataInspectorTab.vue +678 -0
  15. package/dist/runtime/components/DataInspectorTab.vue.d.ts +3 -0
  16. package/dist/runtime/components/LoadingSpinner.d.vue.ts +3 -0
  17. package/dist/runtime/components/LoadingSpinner.vue +12 -0
  18. package/dist/runtime/components/LoadingSpinner.vue.d.ts +3 -0
  19. package/dist/runtime/components/LogsTab.d.vue.ts +3 -0
  20. package/dist/runtime/components/LogsTab.vue +325 -0
  21. package/dist/runtime/components/LogsTab.vue.d.ts +3 -0
  22. package/dist/runtime/components/PowerSyncInstanceTab.d.vue.ts +3 -0
  23. package/dist/runtime/components/PowerSyncInstanceTab.vue +9 -0
  24. package/dist/runtime/components/PowerSyncInstanceTab.vue.d.ts +3 -0
  25. package/dist/runtime/components/SyncStatusTab.d.vue.ts +3 -0
  26. package/dist/runtime/components/SyncStatusTab.vue +272 -0
  27. package/dist/runtime/components/SyncStatusTab.vue.d.ts +3 -0
  28. package/dist/runtime/composables/useDiagnosticsLogger.d.ts +27 -0
  29. package/dist/runtime/composables/useDiagnosticsLogger.js +41 -0
  30. package/dist/runtime/composables/usePowerSyncInspector.d.ts +42 -0
  31. package/dist/runtime/composables/usePowerSyncInspector.js +19 -0
  32. package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.d.ts +153 -0
  33. package/dist/runtime/composables/usePowerSyncInspectorDiagnostics.js +254 -0
  34. package/dist/runtime/composables/usePowerSyncKysely.d.ts +23 -0
  35. package/dist/runtime/composables/usePowerSyncKysely.js +7 -0
  36. package/dist/runtime/index.d.ts +9 -0
  37. package/dist/runtime/layouts/powersync-inspector-layout.d.vue.ts +13 -0
  38. package/dist/runtime/layouts/powersync-inspector-layout.vue +90 -0
  39. package/dist/runtime/layouts/powersync-inspector-layout.vue.d.ts +13 -0
  40. package/dist/runtime/pages/__powersync-inspector.d.vue.ts +3 -0
  41. package/dist/runtime/pages/__powersync-inspector.vue +153 -0
  42. package/dist/runtime/pages/__powersync-inspector.vue.d.ts +3 -0
  43. package/dist/runtime/plugin.client.d.ts +2 -0
  44. package/dist/runtime/plugin.client.js +11 -0
  45. package/dist/runtime/utils/AppSchema.d.ts +27 -0
  46. package/dist/runtime/utils/AppSchema.js +23 -0
  47. package/dist/runtime/utils/DynamicSchemaManager.d.ts +15 -0
  48. package/dist/runtime/utils/DynamicSchemaManager.js +91 -0
  49. package/dist/runtime/utils/JsSchemaGenerator.d.ts +8 -0
  50. package/dist/runtime/utils/JsSchemaGenerator.js +28 -0
  51. package/dist/runtime/utils/NuxtPowerSyncDatabase.d.ts +40 -0
  52. package/dist/runtime/utils/NuxtPowerSyncDatabase.js +117 -0
  53. package/dist/runtime/utils/RecordingStorageAdapter.d.ts +13 -0
  54. package/dist/runtime/utils/RecordingStorageAdapter.js +76 -0
  55. package/dist/runtime/utils/RustClientInterceptor.d.ts +24 -0
  56. package/dist/runtime/utils/RustClientInterceptor.js +102 -0
  57. package/dist/runtime/utils/TokenConnector.d.ts +14 -0
  58. package/dist/runtime/utils/TokenConnector.js +62 -0
  59. package/dist/runtime/utils/addImportsFrom.d.ts +1 -0
  60. package/dist/runtime/utils/addImportsFrom.js +4 -0
  61. package/dist/runtime/utils/index.d.ts +1 -0
  62. package/dist/runtime/utils/index.js +1 -0
  63. package/dist/types.d.mts +9 -0
  64. package/package.json +90 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README ADDED
@@ -0,0 +1,374 @@
1
+ <div align="center">
2
+ <img src="./src/runtime/assets/powersync-icon.svg" alt="PowerSync Logo" width="64" height="64" />
3
+ <h1>PowerSync Nuxt</h1>
4
+ <p>Local-first apps made simple</p>
5
+ <p>Effortless offline-first development with PowerSync integration for Nuxt applications.</p>
6
+ </div>
7
+
8
+ [![npm version][npm-version-src]][npm-version-href]
9
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
10
+ [![License][license-src]][license-href]
11
+ [![Nuxt][nuxt-src]][nuxt-href]
12
+
13
+ PowerSync Nuxt module integrated with the [Nuxt Devtools](https://github.com/nuxt/devtools).
14
+
15
+ - [✨ &nbsp;Release Notes](/CHANGELOG.md)
16
+
17
+ ## Features
18
+
19
+ - 🔍 **Built-in Diagnostics** - Direct access to PowerSync instance monitoring and real-time connection insights
20
+ - 🗄️ **Data Inspection** - Seamless local data browsing with powerful debugging and troubleshooting tools
21
+ - ⚡ **Useful Composables** - Ready-to-use Vue composables for rapid offline-first application development
22
+ - 📦 **All-in-One** - Exposes all `@powersync/vue` composables, making this the only required dependency
23
+
24
+ ## Installation
25
+
26
+ This module exposes all `@powersync/vue` composables, so you only need to install `@powersync/nuxt`:
27
+
28
+ ```bash
29
+ # Using pnpm
30
+ pnpm add -D @powersync/nuxt vite-plugin-top-level-await vite-plugin-wasm
31
+
32
+ # Using yarn
33
+ yarn add --dev @powersync/nuxt vite-plugin-top-level-await vite-plugin-wasm
34
+
35
+ # Using npm
36
+ npm install --save-dev @powersync/nuxt vite-plugin-top-level-await vite-plugin-wasm
37
+ ```
38
+ > [!NOTE]
39
+ > This module works with `Nuxt 4` and should work with `Nuxt 3` but has not been tested. Support for Nuxt 2 is not guaranteed or planned.
40
+
41
+ ## Quick Start
42
+
43
+ 1. Add `@powersync/nuxt` to the `modules` section of `nuxt.config.ts`:
44
+
45
+ ```typescript
46
+ import wasm from 'vite-plugin-wasm'
47
+
48
+ export default defineNuxtConfig({
49
+ modules: ['@powersync/nuxt'],
50
+ vite: {
51
+ optimizeDeps: {
52
+ exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
53
+ include: ['@powersync/web > js-logger'], // <-- Include `js-logger` when it isn't installed and imported.
54
+ },
55
+ worker: {
56
+ format: 'es',
57
+ plugins: () => [wasm()],
58
+ },
59
+ },
60
+ })
61
+ ```
62
+
63
+ > [!WARNING]
64
+ > If you are using Tailwind in your project see [Known Issues section](#known-issues)
65
+
66
+ 2. Create a PowerSync plugin (e.g., `plugins/powersync.client.ts`):
67
+
68
+ ```typescript
69
+ import { NuxtPowerSyncDatabase } from '@powersync/nuxt'
70
+ import { createPowerSyncPlugin } from '@powersync/nuxt'
71
+ import { AppSchema } from '~/powersync/AppSchema'
72
+ import { PowerSyncConnector } from '~/powersync/PowerSyncConnector'
73
+
74
+ export default defineNuxtPlugin({
75
+ async setup(nuxtApp) {
76
+ const db = new NuxtPowerSyncDatabase({
77
+ database: {
78
+ dbFilename: 'your-db-filename.sqlite',
79
+ },
80
+ schema: AppSchema,
81
+ })
82
+
83
+ const connector = new PowerSyncConnector()
84
+
85
+ await db.init()
86
+ await db.connect(connector)
87
+
88
+ const plugin = createPowerSyncPlugin({ database: db })
89
+ nuxtApp.vueApp.use(plugin)
90
+ },
91
+ })
92
+ ```
93
+
94
+ At this point, you're all set to use the module composables. The module automatically exposes all `@powersync/vue` composables, so you can use them directly:
95
+
96
+ - `usePowerSync()` - Access the PowerSync database instance
97
+ - `useQuery()` - Query the database reactively
98
+ - And more... (see [API Reference](#api-reference))
99
+
100
+ ## Setting up PowerSync
101
+
102
+ This guide will walk you through the steps to set up PowerSync in your Nuxt project.
103
+
104
+ ### Create your Schema
105
+
106
+ Create a file called `AppSchema.ts` and add your schema to it.
107
+
108
+ ```typescript
109
+ import { column, Schema, Table } from '@powersync/web'
110
+
111
+ const lists = new Table({
112
+ created_at: column.text,
113
+ name: column.text,
114
+ owner_id: column.text,
115
+ })
116
+
117
+ const todos = new Table(
118
+ {
119
+ list_id: column.text,
120
+ created_at: column.text,
121
+ completed_at: column.text,
122
+ description: column.text,
123
+ created_by: column.text,
124
+ completed_by: column.text,
125
+ completed: column.integer,
126
+ },
127
+ { indexes: { list: ['list_id'] } },
128
+ )
129
+
130
+ export const AppSchema = new Schema({
131
+ todos,
132
+ lists,
133
+ })
134
+
135
+ // For types
136
+ export type Database = (typeof AppSchema)['types']
137
+ export type TodoRecord = Database['todos']
138
+ export type ListRecord = Database['lists']
139
+ ```
140
+
141
+ > **Tip**: Learn more about how to create your schema [here](https://docs.powersync.com/client-sdk-references/javascript-web#1-define-the-schema).
142
+
143
+ ### Create your Connector
144
+
145
+ Create a file called `PowerSyncConnector.ts` and add your connector to it.
146
+
147
+ ```typescript
148
+ import { UpdateType, type PowerSyncBackendConnector } from '@powersync/web'
149
+
150
+ export class PowerSyncConnector implements PowerSyncBackendConnector {
151
+ async fetchCredentials() {
152
+ // Implement fetchCredentials to obtain a JWT from your authentication service.
153
+ // See https://docs.powersync.com/installation/authentication-setup
154
+ // If you're using Supabase or Firebase, you can re-use the JWT from those clients, see
155
+ // - https://docs.powersync.com/installation/authentication-setup/supabase-auth
156
+ // - https://docs.powersync.com/installation/authentication-setup/firebase-auth
157
+ return {
158
+ endpoint: '[Your PowerSync instance URL or self-hosted endpoint]',
159
+ // Use a development token (see Authentication Setup https://docs.powersync.com/installation/authentication-setup/development-tokens) to get up and running quickly
160
+ token: 'An authentication token',
161
+ }
162
+ }
163
+
164
+ async uploadData(db: any) {
165
+ // Implement uploadData to send local changes to your backend service.
166
+ // You can omit this method if you only want to sync data from the database to the client
167
+
168
+ // See example implementation here: https://docs.powersync.com/client-sdk-references/javascript-web#3-integrate-with-your-backend
169
+ // see demos here: https://github.com/powersync-ja/powersync-js/tree/main/demos
170
+ return
171
+ }
172
+ }
173
+ ```
174
+
175
+ > **Tip**: Learn more about how to create your connector [here](https://docs.powersync.com/client-sdk-references/javascript-web#3-integrate-with-your-backend).
176
+
177
+ ### Create your PowerSync Plugin
178
+
179
+ Finally, putting everything together, create a [plugin](https://nuxt.com/docs/4.x/guide/directory-structure/app/plugins) called `powersync.client.ts` to setup PowerSync.
180
+
181
+ ```typescript
182
+ import { createPowerSyncPlugin } from '@powersync/nuxt'
183
+ import { NuxtPowerSyncDatabase } from '@powersync/nuxt'
184
+ import { AppSchema } from '~/powersync/AppSchema'
185
+ import { PowerSyncConnector } from '~/powersync/PowerSyncConnector'
186
+
187
+ export default defineNuxtPlugin({
188
+ async setup(nuxtApp) {
189
+ const db = new NuxtPowerSyncDatabase({
190
+ database: {
191
+ dbFilename: 'a-db-name.sqlite',
192
+ },
193
+ schema: AppSchema,
194
+ })
195
+
196
+ const connector = new PowerSyncConnector()
197
+
198
+ await db.init()
199
+ await db.connect(connector)
200
+
201
+ const plugin = createPowerSyncPlugin({ database: db })
202
+
203
+ nuxtApp.vueApp.use(plugin)
204
+ },
205
+ })
206
+ ```
207
+
208
+ ### Kysely ORM (Optional)
209
+
210
+ You can use Kysely as your ORM to interact with the database. The module provides a `usePowerSyncKysely()` composable:
211
+
212
+ ```typescript
213
+ import { usePowerSyncKysely } from '@powersync/nuxt'
214
+ import { type Database } from '../powersync/AppSchema'
215
+
216
+ // In your component or composable
217
+ const db = usePowerSyncKysely<Database>()
218
+
219
+ // Use the db object to interact with the database
220
+ const users = await db.selectFrom('users').selectAll().execute()
221
+ ```
222
+
223
+ ### Enabling Diagnostics
224
+
225
+ To enable the PowerSync Inspector with diagnostics capabilities:
226
+
227
+ 1. **Enable diagnostics in your config**:
228
+
229
+ ```typescript
230
+ export default defineNuxtConfig({
231
+ modules: ['@powersync/nuxt'],
232
+ powersync: {
233
+ useDiagnostics: true, // <- Add this
234
+ },
235
+ vite: {
236
+ optimizeDeps: {
237
+ exclude: ['@journeyapps/wa-sqlite', '@powersync/web'],
238
+ include: ['@powersync/web > js-logger'],
239
+ },
240
+ worker: {
241
+ format: 'es',
242
+ plugins: () => [wasm()],
243
+ },
244
+ },
245
+ })
246
+ ```
247
+
248
+ When `useDiagnostics: true` is set, `NuxtPowerSyncDatabase` automatically:
249
+ - Extend your schema with diagnostics schema
250
+ - Sets up diagnostics recording
251
+ - Stores the connector internally (accessible via diagnostics)
252
+ - Configures logging for diagnostics
253
+
254
+
255
+ 2. **Accessing PowerSync Inspector**:
256
+
257
+ Once diagnostics are enabled, you can access the [PowerSync Inspector](#powersync-inspector):
258
+
259
+ - **Direct URL**: `http://localhost:3000/__powersync-inspector`
260
+ - **Via Nuxt Devtools**: Open Devtools and look for the PowerSync tab (Instable until proper multitab support for diagnostics in implemented)
261
+
262
+
263
+
264
+ ## PowerSync Inspector
265
+
266
+ PowerSync Inspector is a tool that helps inspect and diagnose the state of your PowerSync client directly from your app in real-time.
267
+
268
+ ### Setup
269
+
270
+ To setup the PowerSync inspector, you need to follow the steps in the [Enabling Diagnostics](#enabling-diagnostics) section.
271
+
272
+ Once setup, the inspector can be accessed on the `http://localhost:3000/__powersync-inspector` route or via the [Nuxt Devtools](#nuxt-devtools).
273
+
274
+ ### Features
275
+
276
+ #### Sync Status
277
+
278
+ The `Sync Status` tab provides a real-time view of the sync status of your PowerSync client, including:
279
+ - Connection status
280
+ - Sync progress
281
+ - Upload queue statistics
282
+ - Error monitoring
283
+
284
+ #### Data Inspector
285
+
286
+ Browse and inspect your local database tables and data with powerful filtering and search capabilities.
287
+
288
+ #### Config Inspector
289
+
290
+ View and inspect your PowerSync configuration, connection options, and schema information.
291
+
292
+ #### Logs
293
+
294
+ Real-time logging of PowerSync operations with syntax highlighting and search functionality.
295
+
296
+ #### Nuxt Devtools
297
+
298
+ The inspector is also available in the Nuxt Devtools as a tab, providing seamless integration with your development workflow.
299
+
300
+ > [!WARNING]
301
+ > Multitab support is still not fully supported when diagnostics are enabled which causes the inspector to malfunction in the devtool. see [Known Issues section](#known-issues)
302
+
303
+ ## Known Issues
304
+
305
+ 1. Enabling diagnostics makes your app glitch when operating in a multi-tab environment. You can observe this issue when you open the inspector in the devtools, for example.
306
+
307
+ 2. PowerSync Inspector relies on `unocss` as a transitive dependency. It might clash with your existing setup, for example if you use Tailwind CSS.
308
+
309
+ To fix this, you can add the following to your `nuxt.config.ts`:
310
+
311
+ ```typescript
312
+ export default defineNuxtConfig({
313
+ unocss: {
314
+ icons: true,
315
+ blocklist: [/\$\{.*\}/],
316
+ content: {
317
+ pipeline: {
318
+ exclude: [
319
+ './layouts/*/**',
320
+ './pages/*/**',
321
+ './components/*/**',
322
+ './composables/*/**',
323
+ './utils/*/**',
324
+ './types/*/**',
325
+ ],
326
+ },
327
+ },
328
+ },
329
+ })
330
+ ```
331
+
332
+ ## Development
333
+
334
+ ```bash
335
+ # Install dependencies
336
+ pnpm install
337
+
338
+ # Generate type stubs
339
+ pnpm run dev:prepare
340
+
341
+ # Run Vitest
342
+ pnpm run test
343
+ pnpm run test:watch
344
+ ```
345
+
346
+ ## Local Testing
347
+
348
+ If the playground is not enough for you, you can test the module locally by cloning this repo and pointing the nuxt app you want to test to the local module.
349
+
350
+ Don't forget to add a watcher for the module for hot reloading.
351
+
352
+ Example (in your nuxt app):
353
+
354
+ ```typescript
355
+ import { defineNuxtConfig } from 'nuxt/config'
356
+
357
+ export default defineNuxtConfig({
358
+ modules: ['../../my-location/@powersync/nuxt/src/*'],
359
+ watch: ['../../my-location/@powersync/nuxt/src/*'],
360
+ })
361
+ ```
362
+
363
+ <!-- Badges -->
364
+ [npm-version-src]: https://img.shields.io/npm/v/@powersync/nuxt/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
365
+ [npm-version-href]: https://npmjs.com/package/@powersync/nuxt
366
+
367
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@powersync/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
368
+ [npm-downloads-href]: https://npmjs.com/package/@powersync/nuxt
369
+
370
+ [license-src]: https://img.shields.io/npm/l/@powersync/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
371
+ [license-href]: https://npmjs.com/package/@powersync/nuxt
372
+
373
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
374
+ [nuxt-href]: https://nuxt.com
@@ -0,0 +1,39 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ /**
4
+ * Configuration options for the PowerSync Nuxt module.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * export default defineNuxtConfig({
9
+ * modules: ['@powersync/nuxt'],
10
+ * powersync: {
11
+ * useDiagnostics: true,
12
+ * },
13
+ * })
14
+ * ```
15
+ */
16
+ interface PowerSyncNuxtModuleOptions {
17
+ /**
18
+ * Enable diagnostics and the PowerSync Inspector.
19
+ *
20
+ * When set to `true`, enables diagnostics recording and makes the PowerSync Inspector available.
21
+ * The inspector provides real-time monitoring, data inspection, and debugging tools.
22
+ *
23
+ * @default false
24
+ */
25
+ useDiagnostics?: boolean;
26
+ /**
27
+ * Enable Kysely integration.
28
+ *
29
+ * When set to `true`, enables the `usePowerSyncKysely` composable for type-safe database queries.
30
+ * Requires `@powersync/kysely-driver` to be installed.
31
+ *
32
+ * @default false
33
+ */
34
+ kysely?: boolean;
35
+ }
36
+ declare const _default: _nuxt_schema.NuxtModule<PowerSyncNuxtModuleOptions, PowerSyncNuxtModuleOptions, false>;
37
+
38
+ export { _default as default };
39
+ export type { PowerSyncNuxtModuleOptions };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "powersync-nuxt",
3
+ "configKey": "powersync",
4
+ "version": "0.1.0",
5
+ "builder": {
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
+ }
9
+ }