- Notifications
You must be signed in to change notification settings - Fork19
Generate TypeScript types from your Sanity.io schemas
License
ricokahler/sanity-codegen
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Note
🎉sanity-codegen
has been superseded bySanity TypeGen 🎉
Exciting news!sanity-codegen
has been superseded bySanity TypeGen!
As the sole maintainer ofsanity-codegen
, I found myself unable to dedicate the time and attention it truly deserved. That's why I'm thrilled to announce the arrival of Sanity TypeGen! This project is a complete replacement forsanity-codegen
and is maintained in-house by the same team that maintains GROQ itselt—you couldn't be in better hands ❤️.
To thesanity-codegen
community — Thank you! 💖
I am deeply grateful for your support, feedback, and contributions to this project and hope you'll continue to offer the same warmth and insightful feedback to the amazing team behind Sanity TypeGen.
🌟Here's to moving forward with Sanity TypeGen! 🌟
Generate TypeScript types from your Sanity schemas and queries
# NOTE: the alpha is required at this timenpm i --save-dev sanity-codegen@alpha
At the root of your sanity project, run:
npx sanity-codegen codegen
This command will locate your schema, generate TypeScript types, and write them tosanity-codegen.d.ts
.
You can also create a configuration file and see other options here.
Thesanity-codegen.d.ts
file that was generated will add ambient types to your project. Access them viaSanity.{WorkspaceName}.Schema.{TypeName}
interfaceProps{ book:Sanity.Default.Schema.Book;// no import needed. just use it}functionyourFunction({ book}:Props){//}
See usage with the@sanity-codegen/client
.
About
Generate TypeScript types from your Sanity.io schemas
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Contributors10
Uh oh!
There was an error while loading.Please reload this page.