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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sandros94/lab

v0.2.0

Published

A personal collection of Nuxt and Nitro tools.

Readme

Sandros94 LAB

npm version npm downloads License Nuxt

A personal collection of Nuxt and Nitro tools. The goal of this project is mainly to simplify my prototyping process and learn a few things about data manipulation, Vitest, CI and others in a laboratory-like environment.

Features

  • useMem: integrates an in-memory kv store, build on-top of unstorage and editable via runtimeConfig (server-only).
  • useFS: integrates a filesystem storage, build on-top of unstorage and editable via runtimeConfig (server-only).
  • useS3 (optional): integrates any S3 compatible storage, build on-top of unstorage and editable via runtimeConfig (server-only).
  • useKV (optional): integrates any Redis compatible KV stores, build on-top of unstorage and editable via runtimeConfig (server-only).
  • useZlib (optional): when enabled, it automatically provides gzip compression and decompression functions to useMem, useFS and useKV (server-only).
  • Built-in validation (optional): using valibot and h3-valibot under the hood (client and server).

Quick Setup

Install the module to your Nuxt application with one command:

npx nuxi module add @sandros94/lab

To enable or disable various features you can simply edit your nuxt.config.ts like so:

export default defineNuxtConfig({
  modules: ['@sandros94/lab'],

  lab: {
    cache: 'kv',  // 'mem', 'fs', 'kv' or null (default)
    s3: true,     // default false
    kv: true,     // default false
    zlib: true,   // default false
    valibot: true // default false
    cms: true     // default false
  }
})

lab.mem, lab.kv and lab.zlib also accept an object to edit their defaults options.

export default defineNuxtConfig({
  modules: ['@sandros94/lab'],

  lab: {
    mem: {
      ttl: 10 * 60,
    },
    fs: {
      base: '.data/myStore', // Default '.data/lab'
    },
    s3: {
      endpoint: 'https://example.com',
      region: 'us-east-1',
      bucket: 'myBucket',
      accessKeyId: '<your-access-key>',      // Best to use env vars
      secretAccessKey: '<your-secret-key>',  // Best to use env vars
    },
    kv: {
      ttl: 10 * 60,
    },
    cms: {
      addRoutes: true, // default true
    }
  }
})

You can also edit them via env vars: NUXT_LAB_{MEM|FS|S3|KV|ZLIB}_*. Useful in situations like editing NUXT_LAB_KV_URL at runtime without rebuilding the application.

Utils

The @sandros94/lab module includes some utility functions:

useMem

Based on unstorage is a custom in-memory driver. It provides added functionality like time-based metadata, optional size calculation and TTL support with auto-purge.

const mem = useMem()

mem.setItem('key', 'value', { ttl: 60 }) // Expires in 60 seconds

const meta = mem.getMeta('key') // { ttl, atime, mtime, ctime, birthtime, size, timeoutId }

When combined with zlib it also receives the following functions:

  • setGzip: Compresses data using gzip and stores it in the KV store.
  • getGzip: Retrieves compressed data from the KV store without decompressing it.
  • getGunzip: Retrieves compressed data from the KV store, decompresses it, and returns the original data.

useFS

Based on useStorage and usestorage's fs driver, to provide runtime-editable support for storing data on the filesystem. It can also be combiled with zlib to provide gzip support as described above (by default a .gz suffix is added to the key).

[NOTE] By default data is stored under .data/lab in the project root. You can change this by setting lab.fs.base in your nuxt.config.ts.

useS3 (optional)

Based on useStorage and usestorage's s3 driver, to provide runtime-editable support with any S3 compatible storages. It can also be combiled with zlib to provide gzip support as described above (by default a .gz suffix is added to the key).

useKV (optional)

Based on useStorage and usestorage's redis driver, to provide runtime-editable support with any Redis compatible KV stores. It can also be combiled with zlib to provide gzip support as described above.

useZlib (optional)

Mainly used internally for useKV, it currently only provides the following functions:

  • gzip: Compresses data using gzip.
  • gunzip: Decompresses gzip-compressed data.

cache (optional)

There is built-in support to use useMem or useKV as a cache provider. You can switch between them by setting lab.cache to either 'mem' or 'kv' or disable it via null (default). This automatically configures Nuxt and Nitro for caching server-side requests and functions.

CMS (optional)

This is a highly experimental feature. Much like Nuxt Content it allows to load static content from a directory in your project (cms by default) and serve it via server util and api routes. The content will be bundled at build time and served both as JSON object (if the format is supported for conversion) and served as is, if the file extension is added in the request.

Supported formats:

  • .json
  • .yaml (.yml)
  • .toml (.tml)
  • .md (.mdc)

[!NOTE] While markdown is supported and parsed via @nuxtjs/mdc under the hood, if you are looking for a proper markdown-based CMS, you should use Nuxt Content instead.

Start by creating a cms directory in your project root and adding some content files.

# cms/hello.yaml
title: Hello World
content: |
  This is a test content.

By default it will be served at /_cms/hello as JSON, but you can also access it as /_cms/hello.yaml to get the raw content.

If you want more control, you can disable the built-in routes via lab.cms.addRoutes: false (in your nuxt.config.ts) and create your own routes:

export default defineEventHandler(async (event) => {
  const slug = getRouterParam(event, 'slug') || 'index'
  const data = await queryStaticContent(slug)

  if (!data) {
    throw createError({
      status: 404,
      message: 'Not found',
    })
  }

  return data
})

Contribution

# Install dependencies
pnpm install

# Generate type stubs
pnpm run dev:prepare

# Develop with the playground
pnpm run dev

# Build the playground
pnpm run dev:build

# Run ESLint
pnpm run lint

# Run Vitest
pnpm run test
pnpm run test:watch

License

Published under the MIT license.