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

@fyit/crouton-assets

v0.1.0

Published

Asset management layer extending nuxt-crouton for centralized media library

Readme

@fyit/crouton-assets

Centralized asset management system for Nuxt Crouton. Provides a full-featured media library with team-based ownership, metadata tracking, and browsing capabilities.

Features

  • 📸 Centralized Asset Library - Single source of truth for all uploads
  • 🎯 Asset Picker UI - Browse and select existing assets with thumbnails
  • 📊 Rich Metadata - Track filename, size, MIME type, alt text, upload date
  • 👥 Team-Based - Assets are scoped to teams/organizations
  • 🔍 Search & Filter - Find assets quickly
  • Accessibility - Alt text support for all images
  • 🌍 i18n Ready - Translatable alt text (with nuxt-crouton-i18n)

Installation

pnpm add @fyit/crouton-assets

Setup

1. Install the package

pnpm add @fyit/crouton-assets

2. Configure Nuxt

Add to your nuxt.config.ts:

export default defineNuxtConfig({
  extends: [
    '@fyit/crouton',
    '@fyit/crouton-assets'  // Add assets layer
  ],
  hub: {
    blob: true  // Required: Enable NuxtHub blob storage
  }
})

3. Generate the assets collection

Use the collection generator to create the assets collection in your project:

crouton-generate core assets --fields-file=node_modules/@fyit/crouton-assets/assets-schema.json --dialect=sqlite

Or create your own schema and generate:

// assets-schema.json
{
  "id": { "type": "string", "meta": { "primaryKey": true } },
  "teamId": { "type": "string", "refTarget": "organisations", "meta": { "required": true } },
  "userId": { "type": "string", "refTarget": "users", "meta": { "required": true } },
  "filename": { "type": "string", "meta": { "required": true } },
  "pathname": { "type": "string", "meta": { "required": true } },
  "contentType": { "type": "string" },
  "size": { "type": "number" },
  "alt": { "type": "string" },
  "uploadedAt": { "type": "date" },
  "updatedBy": { "type": "string", "refTarget": "users" }
}
crouton-generate core assets --fields-file=assets-schema.json --dialect=sqlite

This creates layers/core/collections/assets/ in your project with all the CRUD endpoints and components.

Usage

In Forms (Schema Definition)

Use the asset picker to reference assets by ID:

{
  "imageId": {
    "type": "string",
    "refTarget": "assets",
    "meta": {
      "component": "CroutonAssetsPicker",
      "label": "Featured Image"
    }
  }
}

Direct Upload Component

For simple uploads without the asset library:

<template>
  <CroutonImageUpload
    v-model="imageUrl"
    @file-selected="handleUpload"
  />
</template>

<script setup>
const imageUrl = ref('')

const handleUpload = async (file) => {
  if (!file) return

  const formData = new FormData()
  formData.append('image', file)

  const pathname = await $fetch('/api/upload-image', {
    method: 'POST',
    body: formData
  })

  imageUrl.value = `/images/${pathname}`
}
</script>

Asset Picker Component

Browse and select from existing assets:

<template>
  <CroutonAssetsPicker v-model="selectedAssetId" />
</template>

<script setup>
const selectedAssetId = ref('')
</script>

Architecture

Base Package (nuxt-crouton)

Provides core upload infrastructure:

  • POST /api/upload-image - Upload to blob storage
  • GET /images/[pathname] - Serve from blob storage
  • CroutonImageUpload - Simple file picker component
  • CroutonAvatarUpload - Avatar variant component

Assets Package (this package) - Provides Tools

The package provides reusable components and composables:

  • CroutonAssetsPicker - Browse/select assets UI component
  • CroutonAssetsUploader - Upload + metadata form component
  • useAssetUpload() - Composable for programmatic uploads
  • assets-schema.json - Reference schema for generation

Your Project - Generated Collection

You generate the actual assets collection using crouton-generate:

  • layers/core/collections/assets/ - Generated collection
    • Form.vue, List.vue - CRUD UI
    • API endpoints - GET/POST/PATCH/DELETE at /api/teams/[id]/assets
    • Database schema - Assets table with all metadata
    • Composable - useCoreAssets() with validation

The package tools (CroutonAssetsPicker, CroutonAssetsUploader) work WITH your generated collection.

Simple vs. Full Approach

Simple (Base Package Only)

// Store URL directly in your table
{
  "imageUrl": { "type": "string" }
}

Full Asset Management (With This Package)

// Store asset ID, get all metadata
{
  "imageId": {
    "type": "string",
    "refTarget": "assets",
    "meta": { "component": "CroutonAssetsPicker" }
  }
}

Database Schema

The assets collection includes:

  • id - Unique identifier
  • teamId - Team/organization ownership
  • userId - User who uploaded
  • filename - Original filename
  • pathname - Blob storage path
  • contentType - MIME type
  • size - File size in bytes
  • alt - Alt text (translatable)
  • uploadedAt - Upload timestamp
  • createdAt / updatedAt - Metadata timestamps
  • updatedBy - Last modifier

Requirements

  • Nuxt 4+
  • @fyit/crouton
  • @nuxthub/core with blob storage enabled
  • @vueuse/core

License

MIT © FYIT