Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Can I import some utility for generate keys in same format used by sanity studio?

2 replies
Last updated: Nov 16, 2020
Hello, I'm migrating some data through sanity client using sanity exec. For collections I got this warning after importing new data:
This usually happens when items are created through the API client from outside the Content Studio and someone forgets to set the _key-property of list items.
The value of the _key can be any string as long as it is unique for each element within the array.
The message is clear, I would just like to know if I can import some utility for generate keys in same format used by sanity studio, to maintain uniformity. Thanks
Nov 16, 2020, 3:44 PM
In the Sanity JavaScript client library documentation they use an npm package called
nanoid
to generate the keys
Nov 16, 2020, 3:51 PM
Now I see! Perfect, thank you
Nov 16, 2020, 3:53 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?