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

@pol-studios/storage

v1.0.9

Published

Storage utilities for POL applications

Readme

@pol-studios/storage

Storage utilities for POL applications

Supabase storage integration with hooks for file uploads, URL management, and dropzone functionality. Uses tus-js-client for resumable uploads.

Installation

pnpm add @pol-studios/storage

Peer Dependencies

pnpm add react @tanstack/react-query @supabase/supabase-js react-dropzone @pol-studios/db @pol-studios/utils

Quick Start

import { useUpload, useUrl, useDropzoneUpload, BUCKETS } from "@pol-studios/storage";

function FileUploader() {
  const { upload, isUploading, progress } = useUpload({
    bucket: BUCKETS.documents,
  });

  const handleUpload = async (file: File) => {
    const result = await upload(file, "documents/my-file.pdf");
    console.log("Uploaded:", result);
  };

  return (
    <div>
      <input type="file" onChange={(e) => handleUpload(e.target.files[0])} />
      {isUploading && <progress value={progress} max={100} />}
    </div>
  );
}

Subpath Exports

| Path | Description | |------|-------------| | @pol-studios/storage | All exports (hooks, types, config) | | @pol-studios/storage/hooks | Upload hooks (useUpload, useUrl, usePath, useDropzoneUpload) | | @pol-studios/storage/types | TypeScript type definitions | | @pol-studios/storage/config | Bucket configuration (BUCKETS) |

API Reference

Hooks

useUpload

Upload files to Supabase storage.

import { useUpload, useUploadWithEntity } from "@pol-studios/storage/hooks";

const { upload, isUploading, progress, error } = useUpload({
  bucket: "documents",
  onSuccess: (result) => console.log("Uploaded:", result),
  onError: (error) => console.error("Failed:", error),
});

// Upload a file
await upload(file, "path/to/file.pdf");

// Upload with entity association
const { upload: uploadWithEntity } = useUploadWithEntity({
  bucket: "attachments",
  entityType: "project",
  entityId: projectId,
});

useUrl

Get signed URLs for storage objects.

import { useUrl } from "@pol-studios/storage/hooks";

const { getUrl, url, isLoading } = useUrl({
  bucket: "documents",
  path: "files/document.pdf",
  expiresIn: 3600, // 1 hour
});

// Or manually fetch URL
const signedUrl = await getUrl("another/path.pdf");

usePath

Manage storage paths.

import { usePath } from "@pol-studios/storage/hooks";

const { path, setPath, fullPath } = usePath({
  bucket: "uploads",
  basePath: "users/123",
});

useDropzoneUpload

Integrate with react-dropzone for drag-and-drop uploads.

import { useDropzoneUpload } from "@pol-studios/storage/hooks";

function DropzoneUploader() {
  const {
    getRootProps,
    getInputProps,
    isDragActive,
    files,
    upload,
    isUploading,
    progress,
  } = useDropzoneUpload({
    bucket: "uploads",
    accept: { "image/*": [".png", ".jpg", ".jpeg"] },
    maxFiles: 5,
    maxSize: 10 * 1024 * 1024, // 10MB
  });

  return (
    <div {...getRootProps()}>
      <input {...getInputProps()} />
      {isDragActive ? (
        <p>Drop files here...</p>
      ) : (
        <p>Drag files here or click to select</p>
      )}
      {isUploading && <progress value={progress} max={100} />}
    </div>
  );
}

Configuration

BUCKETS

Pre-defined bucket names.

import { BUCKETS } from "@pol-studios/storage/config";

// Available buckets
BUCKETS.documents;
BUCKETS.images;
BUCKETS.attachments;
// ... etc

TypeScript Types

import type {
  // Upload types
  StorageUploadMetadata,
  StorageObjectMetadata,
  UploadInput,
  UploadResult,
  UseUploadOptions,

  // Attachment types
  Attachment,
  CachedUrl,

  // Path types
  UsePathOptions,
  UsePathResult,

  // Hook return types
  UseSupabaseUploadOptions,
  UseSupabaseUploadReturn,

  // Config types
  BucketName,
} from "@pol-studios/storage";

Features

Resumable Uploads

Uses tus-js-client for resumable uploads, allowing large file uploads to continue after network interruptions.

const { upload } = useUpload({
  bucket: "large-files",
  resumable: true, // Enable resumable uploads
  chunkSize: 6 * 1024 * 1024, // 6MB chunks
});

Progress Tracking

Track upload progress in real-time.

const { progress, bytesUploaded, totalBytes } = useUpload({
  bucket: "uploads",
  onProgress: ({ percentage, bytesUploaded, totalBytes }) => {
    console.log(`${percentage}% uploaded`);
  },
});

Entity Association

Associate uploads with database entities.

const { upload } = useUploadWithEntity({
  bucket: "attachments",
  entityType: "project",
  entityId: "project-123",
  onSuccess: (result) => {
    // result includes entity association metadata
  },
});

Related Packages

License

UNLICENSED