MCPcopy Index your code
hub / github.com/danielroe/zero-vue

github.com/danielroe/zero-vue @v0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.0 ↗ · + Follow
39 symbols 112 edges 20 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

zero-vue

npm version npm downloads Github Actions Codecov

Vue bindings for Zero

Usage

Install package:

# npm
npm install zero-vue

# pnpm
pnpm install zero-vue

Creating useZero and useQuery composables:

import { createZeroComposables } from 'zero-vue'
import { mutators } from './mutators.ts'
import { schema } from './schema.ts'

// see docs for all options: https://zero.rocicorp.dev/docs/introduction
const { useZero, useQuery } = createZeroComposables({
  userID,
  server: import.meta.env.VITE_PUBLIC_SERVER,
  schema,
  mutators,
  kvStore: 'mem',
})

// OR with computed options:
const { useZero, useQuery } = createZeroComposables(() => ({
  userID: userID.value,
  server: import.meta.env.VITE_PUBLIC_SERVER,
  schema,
  mutators,
  kvStore: 'mem',
}))

// OR with a Zero instance:
const { useZero, useQuery } = createZeroComposables({
  zero: new Zero({
    userID,
    server: import.meta.env.VITE_PUBLIC_SERVER,
    schema,
    mutators,
    kvStore: 'mem',
  }),
})

To query data:

import { useQuery, useZero } from './use-zero.ts'

const zero = useZero()
const { data: users } = useQuery(() => zero.value.query.user)

[!TIP] See the playground for a full working example based on rocicorp/hello-zero, or check out danielroe/hello-zero-nuxt to see how to set things up with Nuxt.

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

Credits

The implementation here was based on zero-solid. You can also check out hello-zero-nuxt to see the original implementation and history of this project.

License

Made with ❤️

Published under MIT License.

Extension points exported contracts — how you extend this code

UseQueryOptions (Interface)
(no doc)
src/query.ts
TestReturn (Interface)
(no doc)
src/view.test.ts
ZeroContext (Interface)
(no doc)
playground/src/zero.ts
QueryResult (Interface)
(no doc)
src/query.ts
DefaultTypes (Interface)
(no doc)
playground/src/zero.ts
MaybeQueryResult (Interface)
(no doc)
src/query.ts
DefaultTypes (Interface)
(no doc)
playground/src/db/schema.ts

Core symbols most depended-on inside this repo

createZeroComposables
called by 10
src/create-zero-composables.ts
useZero
called by 10
src/create-zero-composables.ts
push
called by 9
src/view.ts
useQuery
called by 9
src/query.ts
randInt
called by 4
playground/src/utils/rand.ts
destroy
called by 3
src/view.ts
#applyChange
called by 2
src/view.ts
makeError
called by 2
src/view.ts

Shape

Function 22
Method 8
Interface 7
Class 2

Languages

TypeScript100%

Modules by API surface

src/view.ts12 symbols
src/view.test.ts5 symbols
src/create-zero-composables.ts5 symbols
src/query.ts4 symbols
playground/src/utils/rand.ts3 symbols
src/query.test.ts2 symbols
playground/src/zero.ts2 symbols
playground/src/composables/use-interval.ts2 symbols
src/create-zero-composables.test.ts1 symbols
playground/src/utils/date.ts1 symbols
playground/src/db/schema.ts1 symbols
playground/src/db/data/test-data.ts1 symbols

For agents

$ claude mcp add zero-vue \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact