Socket
Socket
Sign inDemoInstall

@vueuse/core

Package Overview
Dependencies
26
Maintainers
4
Versions
346
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vueuse/core

Collection of essential Vue Composition Utilities


Version published
Weekly downloads
1.4M
decreased by-0.09%
Maintainers
4
Install size
1.86 MB
Created
Weekly downloads
 

Package description

What is @vueuse/core?

The @vueuse/core package is a collection of essential Vue Composition API utilities that help with a wide range of common application needs, from state management to utilities for handling side effects. It's designed to work seamlessly with Vue 3, leveraging the Composition API to make building and managing Vue applications easier and more intuitive.

What are @vueuse/core's main functionalities?

State Management

This feature allows you to easily synchronize a reactive state with localStorage, enabling persistent state across page reloads. The example demonstrates how to store and retrieve user settings.

import { ref } from 'vue'
import { useLocalStorage } from '@vueuse/core'

const userSettings = useLocalStorage('user-settings', { theme: 'dark', notifications: true })

Sensor Utilities

Sensor utilities provide reactive access to browser sensors like mouse position. The example shows how to track the mouse position on the screen.

import { useMouse } from '@vueuse/core'

const { x, y } = useMouse()

Animation

This feature enables easy setup of interval-based side effects, useful for animations or regular data fetching. The code sample demonstrates setting up a simple interval that logs a message every second.

import { useIntervalFn } from '@vueuse/core'

const { pause, resume } = useIntervalFn(() => console.log('Tick'), 1000)

Other packages similar to @vueuse/core

Readme

Source

VueUse - Collection of essential Vue Composition Utilities VueUse - Collection of essential Vue Composition Utilities
Collection of essential Vue Composition Utilities

NPM version NPM Downloads Docs & Demos Function Count
GitHub stars

🚀 Features

  • 🎪 Interactive docs & demos
  • 🕶 Seamless migration: Works for both Vue 3 and 2
  • Fully tree shakeable: Only take what you want, bundle size
  • 🦾 Type Strong: Written in TypeScript, with TS Docs
  • 🔋 SSR Friendly
  • 🌎 No bundler required: Usable via CDN
  • 🔩 Flexible: Configurable event filters and targets
  • 🔌 Optional Add-ons: Router, Firebase, RxJS, etc.

🦄 Usage

import { useLocalStorage, useMouse, usePreferredDark } from '@vueuse/core'

export default {
  setup() {
    // tracks mouse position
    const { x, y } = useMouse()

    // if user prefers dark theme
    const isDark = usePreferredDark()

    // persist state in localStorage
    const store = useLocalStorage(
      'my-storage',
      {
        name: 'Apple',
        color: 'red',
      },
    )

    return { x, y, isDark, store }
  },
}

Refer to functions list or documentations for more details.

📦 Install

🎩 From v4.0, it works for Vue 2 & 3 within a single package by the power of vue-demi!

npm i @vueuse/core

Add ons | Nuxt Module

From v6.0, VueUse requires vue >= v3.2 or @vue/composition-api >= v1.1

Demos

CDN

<script src="https://unpkg.com/@vueuse/shared"></script>

<script src="https://unpkg.com/@vueuse/core"></script>

It will be exposed to global as window.VueUse

🪴 Project Activity

Alt

🧱 Contribute

See the Contributing Guide

🌸 Thanks

This project is heavily inspired by the following awesome projects.

And thanks to all the contributors on GitHub!

👨‍🚀 Contributors

Financial Contributors on Open Collective

📄 License

MIT License © 2019-PRESENT Anthony Fu

Keywords

FAQs

Last updated on 27 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc