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

@opencookie-dev/nuxt

v0.2.0

Published

Nuxt module and SSR-safe runtime binding for OpenCookie

Downloads

314

Readme

@opencookie-dev/nuxt

The Nuxt module for OpenCookie's headless external store. It registers one universal Nuxt plugin, installs the existing @opencookie-dev/vue binding, and constructs the application-owned store once per Nuxt application. Consent and policy behavior remain in @opencookie-dev/core.

It supports Nuxt 4, from 4.5.2. A packed Nuxt 4.5.2 application builds and renders with it, and the browser test fixture runs Nuxt 4.5.2. Nuxt 3 reached end of life on 2026-07-31 and no longer receives upstream security updates, so it is no longer supported; 0.1.0 is the last release for Nuxt 3.

Configure the module

Register the module and point it at a module owned by your application:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    [
      "@opencookie-dev/nuxt",
      {
        storeModule: "~/opencookie-store",
      },
    ],
  ],
});

The configured module must default-export a factory. Construct a new store for each Nuxt application. Do not export a mutable module-level singleton because server requests can share module state:

// opencookie-store.ts
import type { OpenCookie } from "@opencookie-dev/core";

import { createOpenCookieStore } from "~/opencookie.config";

export default function createStore(): OpenCookie {
  return createOpenCookieStore();
}

Store construction must be server-safe and deterministic. It must not read window, document, cookies, local storage, the current time, or random IDs. The runtime plugin calls an available initialize() method from Nuxt's app:mounted hook, after hydration. Browser persistence and DOM access belong inside that initialization path.

Read state in Vue components

The runtime entry re-exports the same Vue composables, so no second injection context or subscription is created:

<script setup lang="ts">
import type { OpenCookieSnapshot } from "@opencookie-dev/core";
import { useOpenCookieSnapshot } from "@opencookie-dev/nuxt/runtime";

const snapshot = useOpenCookieSnapshot<OpenCookieSnapshot>();
</script>

<template>
  <output>{{ snapshot.readiness }}</output>
</template>

The module also declares the app-level $openCookie injection for useNuxtApp() and Vue component instances. Its snapshot type is unknown because the application owns the store factory; prefer the generic composables when a component needs the concrete application snapshot type.

<ClientOnly> is not required for a server-safe OpenCookie consumer. The universal plugin installs the provider during both server rendering and client hydration. getServerSnapshot() must return deterministic initial state, and the browser's first render must agree with that state. Fix differing snapshots at their source instead of suppressing hydration warnings or moving the whole banner to a client-only plugin.

Runtime configuration

Nuxt runtime configuration is serialized. Keep functions, stores, Map, and Set values out of runtimeConfig; the storeModule path is a serializable module option and the factory itself remains code. An application-owned factory may call useRuntimeConfig() to read JSON-safe public settings. Only values under runtimeConfig.public are exposed to the browser, so never place secrets there.

Official Nuxt references

Accessed 2026-08-22:

OpenCookie is a technical tool, not legal advice.