New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

storybook-addon-cookie

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storybook-addon-cookie

Storybook addon for setting document.cookie

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51K
increased by19.08%
Maintainers
1
Weekly downloads
 
Created
Source

demo

Support Storybook v8

Starting with storybook-addon-cookie v4.0.0, it supports storybook v8.

storybook v7 -> storybook-addon-cookie v3.x

storybook v6 -> storybook-addon-cookie v2.x

Features

  • Set document.cookie for each Storybook.

Live demo

Installing and Setup

Install addon

With npm:

npm i storybook-addon-cookie -D

Or with yarn:

yarn add storybook-addon-cookie -D

Configure the addon

Add package to storybook configuration.

// .storybook/main.js
module.exports = {
  addons: [
    // ..other addons
    'storybook-addon-cookie',
  ],
};

Usage

You can pass cookie object into cookie parameter.

Or control cookie by addon panel.

export default {
  component: Example,
  title: 'Example',
};

const Template = () => <Example />;

export const WithCookie = Template.bind({});
WithCookie.parameters = {
  cookie: {
    test: 'TEST!',
  },
};

export const WithOutCookie = Template.bind({});

Each Story has independent cookie.

If you want to encode the cookies on the panel, you can use the cookieEncoding option.

export const WithEncodedCookie: Story = {
  parameters: {
    cookie: {
      test: 'TEST!',
    },
    cookieEncoding: true,
  },
};

This option defaults to false.

You can use this option after v3.1.0

Preserve existing cookies

If you want to preserve existing cookies, you can use the cookiePreserve option.

Preserve existing cookies, but only manipulate the ones you specify via parameters.

export const PreserveCookies: Story = {
  parameters: {
    cookie: {
      test: 'TEST!',
    },
    cookiePreserve: true,
  },
};

This option defaults to false.

You can use this option after v3.2.0

Keywords

FAQs

Package last updated on 14 Nov 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