@cliff-studio/sanity-plugin-bunny-input
v1.0.9
Published
Sanity Studio plugin for uploading videos to Bunny Stream
Downloads
50
Readme
@cliffstudio/sanity-plugin-bunny-input
A Sanity Studio plugin for uploading and managing videos via Bunny Stream.
Features
- Drag & drop video uploads directly in Sanity Studio
- Upload progress indicator
- Automatic status polling (uploading → processing → ready)
- Thumbnail preview when video is ready
- Video deletion support
Installation
From GitHub (private repo)
npm install github:cliffstudio/sanity-plugin-bunny-inputOr add to your package.json:
{
"dependencies": {
"@cliffstudio/sanity-plugin-bunny-input": "github:cliffstudio/sanity-plugin-bunny-input"
}
}From npm (if published)
npm install @cliffstudio/sanity-plugin-bunny-inputSetup
1. Get your Bunny Stream credentials
- Log in to bunny.net
- Go to Stream → Create or select a Video Library
- Find your Library ID (numeric ID in the URL or settings)
- Go to API section to find your Stream API Key
2. Add the plugin to your Sanity config
// sanity.config.ts
import {defineConfig} from 'sanity'
import {bunnyInput} from '@cliffstudio/sanity-plugin-bunny-input'
export default defineConfig({
// ... other config
plugins: [
bunnyInput({
libraryId: process.env.SANITY_STUDIO_BUNNY_LIBRARY_ID,
// Optional: auto-create/use this Bunny Stream collection (folder) for uploads
collectionName: process.env.SANITY_STUDIO_BUNNY_COLLECTION_NAME,
// Optional alternative: hardcode an existing collection GUID
// collectionId: process.env.SANITY_STUDIO_BUNNY_COLLECTION_ID,
apiKey: process.env.SANITY_STUDIO_BUNNY_API_KEY,
}),
],
})3. Configure environment variables
For Sanity Studio (.env)
SANITY_STUDIO_BUNNY_LIBRARY_ID=your-library-id
SANITY_STUDIO_BUNNY_COLLECTION_NAME=my-project-videos
# Optional alternative:
# SANITY_STUDIO_BUNNY_COLLECTION_ID=existing-collection-guid
SANITY_STUDIO_BUNNY_API_KEY=your-api-key4. Use in your schemas
import {defineField, defineType} from 'sanity'
export default defineType({
name: 'myDocument',
type: 'document',
fields: [
defineField({
name: 'video',
title: 'Video',
type: 'bunnyVideo',
}),
],
})Collections (folders)
You can route uploads into a Bunny Stream collection (folder):
- Set
collectionIdto use an existing collection GUID directly. - Or set
collectionNameto auto-create/use a collection by name. - If you use
collectionName, the plugin will look up/create that collection before upload.
collectionId takes precedence if both are provided.
Schema
The bunnyVideo type stores:
{
_type: 'bunnyVideo',
videoId: string, // Bunny's GUID
libraryId: string, // Your library ID
collectionId?: string, // Bunny collection GUID (if configured)
collectionName?: string, // Bunny collection name (if configured)
title: string, // Video title
status: 'uploading' | 'processing' | 'ready' | 'error',
thumbnailUrl: string, // Auto-generated thumbnail
playbackUrl: string, // HLS playlist URL
mp4Url: string, // Direct MP4 URL
duration: number, // Duration in seconds
}License
MIT
