Skip to content

Setup

After installing the package, follow these three simple steps to integrate Sanity Structure Tool into your studio.

1. Configuration

First, create a file to configure the plugin. This generates the typed helpers you'll use throughout your project.

ts
import { structureToolPlugin } from 'sanity-plugin-structure-tool';

export const { structure, defineListItems } = structureToolPlugin({
  title: 'My Project',
});

Advanced Configuration

For dynamic titles, custom roles, or workspace support, see the full Configuration Guide.

2. Define List Items

Next, use the generated defineListItems helper to define your studio's desk hierarchy in a separate file.

ts
import { defineListItems } from './index';

const listItems = defineListItems([
  {
    schemaType: 'author',
  },
  {
    title: 'Settings',
    schemaType: 'settings',
    singleton: true,
  },
]);

export default listItems;

Advanced Usage

Learn more about type safety and modular items in the Define List Items Guide.

3. Register the Plugin

Finally, add the structure plugin and the SingletonAction to your sanity.config.ts.

ts
import { defineConfig } from 'sanity';
import { SingletonAction } from 'sanity-plugin-structure-tool';
import { structure } from './src/structure';
import listItems from './src/structure/listItems';

export default defineConfig({
  // ... your studio configuration
  plugins: [
    structure({
      listItems,
    }),
  ],
  document: {
    // Required to handle document actions for singletons
    actions: SingletonAction,
  },
});

What is SingletonAction?

The SingletonAction is essential for singletons to work correctly. It ensures that document actions like "Delete" or "Duplicate" are hidden for singletons, while preserving them for regular documents. Learn more in the Singleton Action Guide.

Verification

To confirm everything is working as expected:

  1. Start your studio:
sh
npm run dev
sh
yarn dev
sh
pnpm dev
sh
bun dev
  1. Navigate to the Structure tab in your browser.
  2. You should see your list items (e.g., "Authors" and "Settings") rendered correctly.

Next Steps

Now that your base setup is complete, explore more:

  • List Items: Learn how to add icons, filters, and custom parameters.
  • Examples: See specific examples for each field.
  • FAQ: Find answers to common questions.

Released under the MIT License.