Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Generate TypeScript types from your Sanity.io schemas

License

NotificationsYou must be signed in to change notification settings

ricokahler/sanity-codegen

Repository files navigation

Note

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! 🌟

Sanity Codegen ✨

Generate TypeScript types from your Sanity schemas and queries

Installation

# NOTE: the alpha is required at this timenpm i --save-dev sanity-codegen@alpha

CLI Usage

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.

Type usage

Schema types

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){//}

Query types (aka GROQ-codegen)

See usage with the@sanity-codegen/client.

About

Generate TypeScript types from your Sanity.io schemas

Topics

Resources

License

Stars

Watchers

Forks

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp