Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including hitchy-plugin-session with all npm packages installed. Try it out:

require("hitchy-plugin-cookies/package.json"); // hitchy-plugin-cookies is a peer dependency. var hitchyPluginSession = require("hitchy-plugin-session")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hitchy-plugin-session v0.1.5

server-side session management for Hitchy


Build Status




In your Hitchy-based application run this command

npm install --save hitchy-plugin-session hitchy-plugin-cookies

to install this plugin.

As illustrated above you are in charge of installing hitchy-plugin-cookies which is a mandatory dependency for this plugin. So, if you get an error regarding some unmet dependency on a role cookies you might need to repeat this command exactly as given.

After restarting Hitchy this plugin is discovered and instantly injecting policy for selecting server-side session by ID provided in cookie passed with every request. Usually, this is done by browsers implicitly. Any request missing cookie with session's ID causes start of another session and injecting instructions for saving cookie in response.

On server side the session is exposed in req.session. It consists of multiple properties:

  • user is provided to expose name and roles of some user. Managing current user is basically out of this plugin's scope. See hitchy-plugin-auth for that.
    • is expected to be a string containing name of current user.
    • user.roles is a list of roles current user is authorized for.
  • data is an object prepared to hold arbitrary data.


This plugin may be customized via section session of configuration. Currently there is no actually supported parameter, but some preparation for selecting backend to use for persisting session data.

Create a file adjusting configuration section session in /config/session.js with content like this:

exports.session = {
    backend: ...

This example doesn't work due to omitting example for configuring backend which isn't supported, yet.


Current version doesn't support persistency, thus all sessions get lost on restarting Hitchy.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free