Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pinia/nuxt

Package Overview
Dependencies
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinia/nuxt

Nuxt Module for pinia

  • 0.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
327K
increased by2.69%
Maintainers
2
Weekly downloads
 
Created

What is @pinia/nuxt?

@pinia/nuxt is a package that integrates Pinia, a state management library, with Nuxt.js, a framework for creating Vue.js applications. This package allows you to manage the state of your application in a more structured and maintainable way, leveraging the capabilities of both Pinia and Nuxt.js.

What are @pinia/nuxt's main functionalities?

State Management

This feature allows you to define a store with state and actions. In this example, a counter store is defined with a state property 'count' and an action 'increment' to modify the state.

export const useCounterStore = defineStore('counter', {
  state: () => ({
    count: 0
  }),
  actions: {
    increment() {
      this.count++;
    }
  }
});

Nuxt Integration

This feature demonstrates how to integrate Pinia with a Nuxt.js project. The configuration includes the @pinia/nuxt module and sets up auto-imports for commonly used Pinia functions.

export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt',
  ],
  pinia: {
    autoImports: [
      'defineStore',
      'storeToRefs',
    ],
  },
});

Using Stores in Components

This feature shows how to use a Pinia store within a Nuxt.js component. The counter store is imported and used to display and modify the count state.

<template>
  <div>
    <p>{{ count }}</p>
    <button @click="increment">Increment</button>
  </div>
</template>

<script setup>
import { useCounterStore } from '~/stores/counter';
const counterStore = useCounterStore();
const { count } = storeToRefs(counterStore);
const { increment } = counterStore;
</script>

Other packages similar to @pinia/nuxt

Keywords

FAQs

Package last updated on 04 Dec 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc