npm @sanity/cli 3.0.0-rc.0
v3.0.0-rc.0

latest releases: 3.61.0, 3.60.0, 3.59.2-canary.33...
23 months ago

Sanity Studio v3: Release Candidate

This is the first Release Candidate of Sanity Studio v3. That means that you can expect APIs marked @public to be stable going forward. We are still ironing out bugs and making improvements, and appreciate any input or questions you might have.

We also want to invite you to a Sanity virtual event on December 8th, where we will dive into customer stories, demos, and talk about where the Sanity platform is headed.

You might also want to check out the notes for recent releases.

Installation and upgrading

To globally install/upgrade the v3 Sanity CLI:

npm install --global sanity@dev-preview

To validate you're on @3.0.0-rc.0:

$ sanity --version
> sanity version 3.0.0-rc.0

The new CLI should work with existing v2 studios, but you won't be able to initialize new v2 studios with it.

To initiate a new Studio without installing the CLI globally:

npx create-sanity@dev-preview

To upgrade a v3 Studio:

npm install sanity@3.0.0-rc.0

Make sure your package.json are up to date with these dependencies:

{
  "dependencies": {
    // if you’re depending on `@sanity/ui`
    "@sanity/ui": "1.0.0-beta.32",
    "sanity": "3.0.0-rc.0"
  }
}

You might also have to upgrade your Sanity v3 plugins to their latest versions. The following command might be useful for checking for plugin updates:

npx npm-check-updates --target @studio-v3 --filter sanity

Breaking change: sanity start is now sanity dev

In Studio v2 and earlier developer preview releases, the command sanity start was used to start the development server. To better align with other frameworks such as Next.js, Remix, and Gatsby, we have renamed the command to sanity dev. The sanity start command is now used to start a static server that can be used to preview a production build (it is also available as sanity preview).

For existing studios, you might want to add a new dev npm script to your package.json file to make sure your team knows about the change:

{
  // ...
  "scripts": {
    "build": "sanity build",
    "dev": "sanity dev",
    "deploy": "sanity deploy",
    "start": "sanity start"
  }
}

Breaking change: createConfig is now defineConfig

To better align with other frameworks, we have renamed the following create-methods:

  • createConfig -> defineConfig
  • createCliConfig -> defineCliConfig
  • createPlugin -> definePlugin

The old create-methods will still work for the time being, but are deprecated and will be removed prior to the final release of v3.

Beta: Add custom functionality to array inputs

It is now possible to customize the array input with custom functions. The API allows you to replace the Add button and exposes different methods through its properties for interacting with array content.

This feature also introduces breaking changes for callback namings and typings (see below).

Example of custom array functionality in defineConfig:

// sanity.config.ts

import {defineConfig, isArrayOfPrimitivesInputProps} from 'sanity'

function MyArrayFunction(props) {
  const {onItemAppend} = props

  const handleAdd = useCallback(() => {
    // Adds 'Hello!' to new string items in the array
    onItemAppend('Hello!')
  }, [onItemAppend])

  return <Button text={`Add "Hello!" to the array`} onClick={handleAdd} />
}

export default defineConfig({
  // ...,
  // other config
  form: {
    components: {
      input: (props) => {
        const {renderDefault}  = props

        // Check if the input is an array of primitives (strings etc)
        if (isArrayOfPrimitivesInputProps(props)) {
          return renderDefault({...props, arrayFunctions: MyArrayFunction})
        }

        return renderDefault(props)
      },
    },
  },
})

For feedback and questions on this API, go to GitHub Discussions.

Breaking change: Advanced input component callbacks

We've aligned our API naming policy for callbacks to be on<Subject><Verb>. For improved consistency, we have renamed the following callbacks:

  • onFocusPath -> onPathFocus
  • onCollapseFieldSet -> onFieldSetCollapse
  • onExpandFieldSet -> onFieldSetExpand
  • onCollapseField -> onFieldCollapse
  • onExpandField -> onFieldExpand
  • onOpenField -> onFieldOpen
  • onOpenItem -> onItemOpen
  • onCloseItem -> onItemClose
  • onRemoveItem -> onItemRemove
  • onPrependItem -> onItemPrepend
  • onAppendItem -> onItemAppend
  • onCollapseItem -> onItemCollapse
  • onExpandItem -> onItemExpand
  • onCreateValue -> onValueCreate

These callbacks are mostly used for complex custom object/array inputs.

Breaking change: Array functions components/types

We've improved "array functions" - see above. With this change comes a few naming changes:

  • DefaultArrayOfPrimitivesFunctions -> ArrayOfPrimitivesFunctions
  • DefaultArrayFunctions -> ArrayOfObjectsFunctions
  • FormArrayInputFunctionsProps -> ArrayInputFunctionsProps

The default array functions components (ArrayOfPrimitivesFunctions and ArrayOfObjectsFunctions) are now exported from the sanity package.

All default input components are now exported

All the standard inputs are now exported and available in the sanity package for use when building custom input components.

Notable bugfixes

  • Fixed an issue where the review changes panel might not use the selected document revision, and the content form would go into read-only mode

📓 Full changelog

Author Message Commit
Espen Hovlandsdal chore(portable-text-editor): temporarily disable collaborative tests while flakey d38169f
Marius Lundgård chore(deps): update dependencies c28a445
Marius Lundgård fix(sanity): update popover placements 19d0e70
Espen Hovlandsdal feat(server): expose vite preview server integration 928229f
Espen Hovlandsdal feat(cli): add new sanity preview command 8e8e05d
Espen Hovlandsdal refactor(cli): rename start command to dev 70ddf06
Espen Hovlandsdal feat(cli): add sanity start alias for sanity preview 8f04628
Espen Hovlandsdal fix(cli): add dev npm script to package.json 9f92d16
Espen Hovlandsdal fix(cli): use correct coloring for warning label f18f17f
Espen Hovlandsdal chore: drop http-server dependency, use sanity start command f769800
Espen Hovlandsdal fix(cli): add preview to list of known core commands bfe3146
Espen Hovlandsdal test(form): update snapsnot to align with @sanity/ui update 603b893
Espen Hovlandsdal refactor(cli): improve help text on start/preview commands ce93ab2
Snorre Eskeland Brekke feat: added components definitions for all intrinsic schema-types ae0d13d
Snorre Eskeland Brekke chore: fields no longer require at least on field in definition types ae58cc5
Snorre Eskeland Brekke fix: added optional placeholder prop to definition types that support it 81db048
Snorre Eskeland Brekke chore: fix compile tests 4889b3b
Snorre Eskeland Brekke chore: added doc-tags 04f4260
Snorre Eskeland Brekke chore: added missing doc-tags b97b1b3
Fred Carlsen fix(sanity): fix icon from schema in block previews (#3725) b07a9b5
Bjørge Næss fix(form): fix field group state not propagated through arrays 164d152
Snorre Eskeland Brekke chore: make type specific components assignable to union types for input, form and item 3a83d63
Per-Kristian Nordnes test(portable-text-editor): fix issues with test env config f64ef8d
Per-Kristian Nordnes test(portable-text-editor): make tests async 79d2fed
Per-Kristian Nordnes Revert "chore(portable-text-editor): temporarily disable collaborative tests while flakey" 90db84a
Per-Kristian Nordnes test(portable-text-editor): run tests in band (sync) ab897dc
Per-Kristian Nordnes test(portable-text-editor): update comments 0c2cdf0
Herman Wikner refactor(form): remove ArrayFunctions from config c6cf601
Herman Wikner refactor(form): update typing in TagsArrayInput 9c3c46a
Herman Wikner feat(form): add custom array functions to GridArrayInput 16d44ba
Herman Wikner feat(form): add custom array functions to ListArrayInput ca70b8f
Herman Wikner feat(form): add custom array functions to ArrayOfPrimitivesInput 8a3d806
Herman Wikner test(form): add custom array functions test c2dc85c
Herman Wikner dev(test-studio): test array functions in schema 063f49f
Herman Wikner refactor(form): unify naming of array components and types 7d9d2d8
Herman Wikner chore(form): export ArrayOfObjectsFunctions and ArrayOfPrimitivesFunctions 76ac511
Robin Pyon chore(deps): update react-virtual f5f0d26
Espen Hovlandsdal refactor: use ReturnType on setTimeout instead of NodeJS.Timeout 450c002
Snorre Eskeland Brekke feat: all field inputs are now exported and can be used in Studio code 0b2c1cd
Per-Kristian Nordnes test(portable-text-editor): robustify tests for running in paralell 07c1ef9
Snorre Eskeland Brekke feat: documentStore is now available in StructureContext 3f2b888
Marius Lundgård fix(server): configure cacheDir to avoid cache conflicts 8f0d993
Marius Lundgård fix(server): add missing require path c03e16e
Cody Olsen chore: add some 3d to the test studio 58ed907
Cody Olsen chore: streamline suspense on 3d demos 9f48580
Cody Olsen chore(3D): support prefers reduced motion 4fd9ab6
Cody Olsen chore(3D): stop animating on pointer leave 8784f6c
Cody Olsen chore(3D): use detail layout on demos a2c05aa
Cody Olsen chore(3D): add presence demo f6c80a8
Herman Wikner dev(test-studio): clean up sanity.config ddcd00f
Herman Wikner fix(core): use the default error screen when there are configuration errors 6cff8b9
Herman Wikner fix(core): tool menu focus issue 9f9ba22
Fred Carlsen refactor(form-builder): simplify cross dataset reference config (#3670) (#3811) 36419e2
Espen Hovlandsdal fix(schema): validate that component properties are react components 0f62a23
Espen Hovlandsdal refactor: rename createConfig to defineConfig b8fe8e9
Espen Hovlandsdal chore: add publish-rc script f3845ce
Espen Hovlandsdal chore: upgrade @sanity/ui, @sanity/color, @sanity/icons 5bb2720
Bjørge Næss fix(desk-tool): fix: earlier revision not appearing in form e59be18

Don't miss a new cli release

NewReleases is sending notifications on new releases.