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

sanity-search-and-delete

v1.0.0

Published

Flexible search and delete utility for Sanity Studio - bulk content management with safety features

Downloads

1

Readme

Sanity Search and Delete

A flexible search and delete utility for Sanity Studio that enables bulk content management with comprehensive safety features. Works with any document type and provides powerful search capabilities.

Features

  • 🔍 Flexible Search: Search across any document type with multiple criteria
  • 🎯 Custom GROQ Queries: Advanced users can write custom queries
  • 🛡️ Safety First: Confirmation dialogs, dry-run mode, and batch processing
  • 📊 Progress Tracking: Real-time feedback during operations
  • Selective Deletion: Choose exactly which documents to delete
  • 🔄 Batch Processing: Handles large datasets efficiently
  • 📱 Responsive UI: Works seamlessly in Sanity Studio

Installation

npm install sanity-search-and-delete

Quick Start

Basic Usage

import React from 'react'
import { SearchAndDelete } from 'sanity-search-and-delete'
import { useClient } from 'sanity'

const MyUtilityPage = () => {
  const client = useClient({ apiVersion: '2023-01-01' })

  return (
    <SearchAndDelete
      client={client}
      onComplete={(results) => {
        console.log(`Deleted ${results.deleted} items`)
      }}
    />
  )
}

As a Sanity Studio Tool

// sanity.config.ts
import { defineConfig } from 'sanity'
import { SearchAndDeleteTool } from 'sanity-search-and-delete'

export default defineConfig({
  // ... other config
  tools: [
    SearchAndDeleteTool()
  ]
})

With Specific Document Types

<SearchAndDelete
  client={client}
  documentTypes={['post', 'page', 'author']}
  maxResults={50}
  batchSize={5}
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | client | SanityClient | required | Sanity client instance | | documentTypes | string[] | [] | Specific document types to search (empty = all types) | | onComplete | function | undefined | Callback when deletion completes | | onError | function | undefined | Error handling callback | | batchSize | number | 10 | Number of items to delete per batch | | dryRun | boolean | false | Preview mode without actual deletion | | maxResults | number | 100 | Maximum search results to display |

Usage Examples

1. Basic Content Cleanup

import { SearchAndDelete } from 'sanity-search-and-delete'

const ContentCleanup = () => {
  const client = useClient({ apiVersion: '2023-01-01' })

  return (
    <SearchAndDelete
      client={client}
      documentTypes={['post', 'page']}
      onComplete={(results) => {
        if (results.errors.length > 0) {
          console.error('Some deletions failed:', results.errors)
        } else {
          console.log(`Successfully deleted ${results.deleted} items`)
        }
      }}
    />
  )
}

2. Safe Mode with Dry Run

<SearchAndDelete
  client={client}
  dryRun={true}
  onComplete={(results) => {
    console.log(`Would delete ${results.deleted} items`)
  }}
/>

3. Custom Error Handling

<SearchAndDelete
  client={client}
  onError={(error) => {
    // Custom error handling
    toast.error(`Operation failed: ${error}`)
  }}
  onComplete={(results) => {
    if (results.deleted > 0) {
      toast.success(`Deleted ${results.deleted} items`)
    }
  }}
/>

Search Capabilities

Built-in Search Fields

The component automatically searches across common fields:

  • title
  • name
  • slug.current
  • Document ID

Custom GROQ Queries

For advanced users, enable custom GROQ queries:

*[_type == "post" && dateTime(_createdAt) < dateTime("2023-01-01")]
*[_type == "author" && !defined(bio)]

Safety Features

Confirmation Dialogs

  • All delete operations require explicit confirmation
  • Clear warning messages for destructive actions
  • Separate confirmation for dry-run vs actual deletion

Dry Run Mode

<SearchAndDelete client={client} dryRun={true} />
  • Preview what would be deleted without making changes
  • Test queries and filters safely
  • Validate batch sizes and operations

Batch Processing

  • Large deletions are processed in configurable batches
  • Prevents timeout issues with large datasets
  • Progress feedback during long operations

Requirements

  • Sanity Studio v3+
  • React 18+
  • @sanity/ui v1+
  • TypeScript 4.5+ (optional)

License

MIT License - see LICENSE file for details.