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

@astracollab/nextjs

v0.0.1

Published

AstraCollab SDK for Next.js

Readme

@astracollab/nextjs

AstraCollab Next.js SDK with React hooks and components for file uploads.

Features

  • 🚀 Decoupled Architecture: Use the upload service without UI, or with our pre-built components
  • 📁 File Upload Management: Handle single and multiple file uploads with progress tracking
  • 🔄 Real-time Progress: Track upload progress with Web Workers for smooth UI updates
  • 🎨 Flexible UI: Use our pre-built components or create your own UI
  • 🔧 TypeScript Support: Full TypeScript support with comprehensive type definitions
  • Next.js Optimized: Built specifically for Next.js applications
  • 📦 Zero Configuration: Includes all necessary dependencies (React Query, Axios, etc.)

Installation

npm install @astracollab/nextjs
# or
yarn add @astracollab/nextjs
# or
pnpm add @astracollab/nextjs

Note: This package automatically installs @tanstack/react-query and axios as dependencies, so you don't need to install them separately.

Quick Start

1. Basic Usage with Pre-built UI

import { FileUploaderWithUI } from '@astracollab/nextjs';

function MyComponent() {
  const config = {
    baseURL: 'https://api.astracollab.app',
    apiKey: 'your-api-key'
  };

  return (
    <FileUploaderWithUI
      config={config}
      folderId="optional-folder-id"
      orgId="optional-org-id"
      maxFiles={5}
      onUploadComplete={(results) => {
        console.log('Upload completed:', results);
      }}
      onUploadError={(error, fileId) => {
        console.error('Upload failed:', error);
      }}
    />
  );
}

2. Custom UI with Upload Service

import { useUploadService, useUpload } from '@astracollab/nextjs';

function CustomUploader() {
  const config = {
    baseURL: 'https://api.astracollab.app',
    apiKey: 'your-api-key'
  };

  const uploadService = useUploadService(config);
  const { uploadFiles, uploadProgress, isUploading } = useUpload(uploadService);

  const handleFileSelect = (event) => {
    const files = Array.from(event.target.files);
    uploadFiles(files);
  };

  return (
    <div>
      <input type="file" multiple onChange={handleFileSelect} />
      {isUploading && <p>Uploading files...</p>}
      
      {/* Display progress for each file */}
      {Array.from(uploadProgress.entries()).map(([fileId, progress]) => (
        <div key={fileId}>
          <p>{progress.fileName}: {progress.progressPercentage}%</p>
        </div>
      ))}
    </div>
  );
}

3. Using the Upload Service Directly

import { UploadService } from '@astracollab/nextjs';

const uploadService = new UploadService('https://api.astracollab.app', 'your-api-key');

// Upload a single file
const fileId = await uploadService.uploadSingleFile({
  file: fileObject,
  fileName: 'example.jpg',
  folderId: 'optional-folder-id',
  orgId: 'optional-org-id'
});

// Upload multiple files
await uploadService.uploadMultipleFiles({
  files: [
    { id: '1', file: file1, name: 'file1.jpg', size: 1024 },
    { id: '2', file: file2, name: 'file2.jpg', size: 2048 }
  ],
  folderId: 'optional-folder-id',
  orgId: 'optional-org-id',
  onProgress: (progressMap) => {
    console.log('Upload progress:', progressMap);
  },
  onError: (errorMsg, fileId) => {
    console.error('Upload error:', errorMsg);
  },
  onSuccess: (results) => {
    console.log('Upload success:', results);
  }
});

API Reference

Components

FileUploaderWithUI

A complete file upload component with drag-and-drop interface and progress tracking.

<FileUploaderWithUI
  config={UploadServiceConfig}
  folderId?: string
  orgId?: string
  maxFiles?: number
  onUploadComplete?: (results: { fileId: string; fileName: string; }[]) => void
  onUploadError?: (error: string, fileId: string) => void
  onUploadProgress?: (progressMap: Map<string, FileUploadProgress>) => void
  className?: string
  dropzoneClassName?: string
  listClassName?: string
  itemClassName?: string
  buttonClassName?: string
  progressBarClassName?: string
  statusClassName?: string
/>

FileUploader

A minimal file upload component without UI styling.

<FileUploader
  config={UploadServiceConfig}
  folderId?: string
  orgId?: string
  maxFiles?: number
  onUploadComplete?: (results: { fileId: string; fileName: string; }[]) => void
  onUploadError?: (error: string, fileId: string) => void
  onUploadProgress?: (progressMap: Map<string, FileUploadProgress>) => void
  className?: string
  children?: React.ReactNode
/>

Hooks

useUploadService

Creates and manages an upload service instance.

const uploadService = useUploadService({
  baseURL: string
  apiKey?: string
  timeout?: number
});

useUpload

Provides upload functionality with progress tracking.

const {
  uploadFiles,
  uploadProgress,
  isUploading,
  cancelUpload,
  clearProgress
} = useUpload(uploadService);

useFiles

Fetches files from the API.

const {
  files,
  isLoading,
  error,
  refetch
} = useFiles(baseURL, apiKey, folderId, orgId);

UploadService

The core upload service class.

const uploadService = new UploadService(baseURL, apiKey);

// Methods
uploadService.uploadSingleFile(options: SingleFileUploadOptions): Promise<string>
uploadService.uploadMultipleFiles(config: UploadBatchConfig): Promise<void>
uploadService.cancelUpload(fileId: string): void
uploadService.getProgress(fileId: string): FileUploadProgress | undefined
uploadService.getAllProgress(): Map<string, FileUploadProgress>
uploadService.clearProgress(fileId: string): void
uploadService.clearAllProgress(): void
uploadService.addProgressListener(listener: (progressMap: Map<string, FileUploadProgress>) => void): void
uploadService.removeProgressListener(listener: (progressMap: Map<string, FileUploadProgress>) => void): void

Types

FileUploadProgress

interface FileUploadProgress {
  fileId: string;
  fileName: string;
  totalBytes: number;
  uploadedBytes: number;
  progressPercentage: number;
  status: 'pending' | 'uploading' | 'completed' | 'failed' | 'canceled';
  error?: string;
}

UploadServiceConfig

interface UploadServiceConfig {
  baseURL: string;
  apiKey?: string;
  timeout?: number;
}

SingleFileUploadOptions

interface SingleFileUploadOptions {
  file: File;
  fileName?: string;
  folderId?: string;
  orgId?: string;
  onProgress?: (progress: number) => void;
}

Examples

Custom Styling

<FileUploaderWithUI
  config={config}
  className="my-uploader"
  dropzoneClassName="custom-dropzone"
  buttonClassName="custom-button"
  progressBarClassName="custom-progress"
/>

Custom File Input

<FileUploader config={config}>
  <button className="my-custom-button">
    Choose Files
  </button>
</FileUploader>

Progress Tracking

function UploadWithProgress() {
  const [progress, setProgress] = useState(new Map());
  
  return (
    <FileUploaderWithUI
      config={config}
      onUploadProgress={setProgress}
    />
  );
}

Dependencies

This package includes the following dependencies:

  • @tanstack/react-query - For data fetching and caching
  • axios - For HTTP requests
  • uuid - For generating unique identifiers

You don't need to install these separately - they're automatically included when you install @astracollab/nextjs.

License

MIT