Joint session with Vercel: How to build intelligent storefronts (May 15th)

Bou Optimizer

Optimize Image or PDF assets during upload

By Teemu Lahjalahti

Install command

npm i @bou-co/optimizer-sanity-plugin

Bou Optimizer - Sanity Plugin

Use https://optimizer.bou.app/ inside your Sanity Studio to optimize images during upload.

Bou Image and PDF optimizer in Sanity Studio

NPM | GitHub

Usage

Install the package from NPM:

npm i @bou-co/optimizer-sanity-plugin

Add the plugin in your Sanity Studio config:

// sanity.config.ts
import { defineConfig } from 'sanity';
import { structureTool } from 'sanity/structure';
import { schemaTypes } from './schemas';

// Import the "bouOptimizer" plugin
import { bouOptimizer } from '@bou-co/optimizer-sanity-plugin';

export default defineConfig({
  projectId: '<projectId>',
  dataset: 'production',
  plugins: [
    structureTool(),
    // Add "bouOptimizer" as a plugin to your config
    bouOptimizer(),
  ],
  schema: {
    types: schemaTypes,
  },
});

Use the new asset source from any file/image field:

use bou image optimizer