vite-plugin-vue-server-ref weekly downloads statistics
By antfu (15 listings) · npm · Vite plugins
Share state between clients and Vite server
vite-plugin-vue-server-ref has 300,647 recorded weekly downloads on npm, an increase of 37.0% over the past 30 days, ranking #468 of 3,247 tracked listings.
About vite-plugin-vue-server-ref
vite-plugin-vue-server-ref
Share state between clients and Vite server.
Install
npm i -D vite-plugin-vue-server-ref
Add plugin to your vite.config.ts:
// vite.config.ts
import ServerRef from 'vite-plugin-vue-server-ref'
export default {
plugins: [
ServerRef({
state: {
/* Your custom initial state */
foo: 'bar',
object: {
count: 0
}
}
})
]
}
Use import it in your modules (server-ref:[key])
import foo from 'server-ref:foo'
console.log(foo.value) // bar
foo.value = 'foobar'
// same as other modules / clients imported the server ref with same key
// or even refresh the pages
console.log(foo.value) // foobar
Or working with reactive object (server-reactive:[key])
import object from 'server-reactive:object'
console.log(object.count) // 0
Type Support
As server import can't infer the type correctly (by default it's ServerRef<any>), you can using as to specify the type.
import type { ServerReactive, ServerRef } from 'vite-plugin-vue-server-ref/client'
import _foo from 'server-ref:foo'
import _object from 'server-ref:object'
const foo = _foo as ServerRef<string>
const object = _object as ServerReactive<{ count: number }>
foo.value // string
object.count // number
Controls
import foo from 'server-ref:foo'
foo.$syncUp = false // make it download only
foo.value = 'foobar' // won't send to server or other clients
import foo from 'server-ref:foo'
foo.$syncDown = false // make it upload only
// changes from other clients won't be received
import foo from 'server-ref:foo'
// listen to server change
foo.$onSet((value) => {
console.log(`Changes from server: ${value}`)
})
Diffing
When working with reactive objects, you can add ?diff to make the syncing incremental (deep diff).
import object from 'server-ref:object?diff'
console.log(object) // { foo: ..., bar: ... }
object.foo.nested = 'bar'
// the patch will be sent as '{ foo: { nested: 'bar' }}}'
// instead of the entire object
Sponsors
<p align="center"> <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/> </a> </p>License
MIT License © 2021 Anthony Fu
Description from the npm listing.
- vite-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 vite-plugin-vue-server-ref alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-vue-server-ref. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.