# zero-vue [![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] > Vue bindings for [Zero](https://zero.rocicorp.dev/) ## Usage Install package: ```sh # npm npm install zero-vue # pnpm pnpm install zero-vue ``` Creating `useZero` and `useQuery` composables: ```ts 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: ```js import { useQuery, useZero } from './use-zero.ts' const zero = useZero() const { data: users } = useQuery(() => zero.value.query.user) ``` > [!TIP] > See [the Vue fixture](./test/fixtures/vue) or [the Nuxt fixture](./test/fixtures/nuxt) for full working examples based on [rocicorp/hello-zero](https://github.com/rocicorp/hello-zero). ## 💻 Development - Clone this repository - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` - Install dependencies using `pnpm install` - Run interactive tests using `pnpm dev` ## Credits The implementation here was based on [zero-solid](https://github.com/rocicorp/mono/tree/main/packages/zero-solid). You can also check out [hello-zero-nuxt](https://github.com/danielroe/hello-zero-nuxt) to see the original implementation and history of this project. ## License Made with ❤️ Published under [MIT License](./LICENCE). [npm-version-src]: https://npmx.dev/api/registry/badge/version/zero-vue [npm-version-href]: https://npmx.dev/package/zero-vue [npm-downloads-src]: https://npmx.dev/api/registry/badge/downloads/zero-vue [npm-downloads-href]: https://npm.chart.dev/zero-vue [github-actions-src]: https://img.shields.io/github/actions/workflow/status/danielroe/zero-vue/ci.yml?branch=main&style=flat-square [github-actions-href]: https://github.com/danielroe/zero-vue/actions?query=workflow%3Aci [codecov-src]: https://img.shields.io/codecov/c/gh/danielroe/zero-vue/main?style=flat-square [codecov-href]: https://codecov.io/gh/danielroe/zero-vue