npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dwy-vue-session

v1.0.9

Published

A vue front-end session plugin

Readme

VueSession

A vue front-end session plugin

Install

$ npm install dwy-vue-session --save

Import

script
<script src="../node_modules/vue-session/dist/vue-session.js"></script>
es2015
  import Session from 'dwy-vue-session'
cmd
  var VueSession=require('dwy-vue-session');

Usage

import VueSession from 'dwy-vue-session'

//in main.js,mount Session's instance to Vue's prototype via Vue.use
//then you can access session via every Vue's instance
Vue.use(Session);

//when signedin,
//call instance method regenerate to generate session;
this.$session.regenerate(token);


//judge signin state
if(this.$session.signedin){
  //do something
}

//when signout,call method destroy to destroy the session;
this.$session.destroy();

Example

  1. main.js
import Vue from 'vue'
import VueSession from 'dwy-vue-session'

Vue.use(VueSession,{
  maxAge:1000*60*60*24,
  prefix:'app'
});
  1. signin.vue
<script>
  import AuthService from '../auth.service'
  
  export default{
    data(){
      return {
        username:'',
        password:''
      }
    },
    method:{
      onSubmit(){
        let {username,password}=this;
        AuthService.signin(username,password)
        .then(token=>{
          this.$session.regenerate(token);
        });
      }
    }
  }
</script>
  1. profile.vue
<script>
  import VueSession from 'dwy-vue-session'
  import AuthService from '../auth.service'
  export default{
      data(){
        return {
          profile:null
        }
      },
      beforeRouteEnter(to,from,next){
        //in beforeRouteEnter hook
        //we can not access `this`
        //but can access session via Session's static method `getInstance`
        let session=VueSession.getInstance();
        if(session.signedin){
          return next();
        }
        next('/signin');
      },
      methods:{
        onSignoutButtonClick(){
          AuthService.signout()
            .then(()=>{
              this.$session.destroy();
              this.$router.push('/signin');
            });
        }
      }
    }
</script>

API

constructor params;

  1. maxAge session expire time ,default:7200000ms.
  2. prefix localstorage key prefix,default:vue-session.

instance

  1. token property,readonly;
  2. createAt property,readonly;
  3. signedin property,readonly;
  4. regenerate method,call it to generate session;
  5. destroy method,call it to destroy session;

Test

$ npm test