Here’s a cleaner and more polished version of your README.md
content:
This guide demonstrates how to implement TypeScript type generation (typegen
) with Next.js 15 and the latest version of Sanity CMS.
Add the following command to the scripts
section of your package.json
file:
"typegen": "sanity schema extract --path=./src/sanity/extract.json && sanity typegen generate"
Example screenshot for reference:
create a new json file in your root directory:
sanity-typegen.json
{
"path": "./src/**/*.{ts,tsx,js,jsx}",
"schema": "./src/sanity/extract.json",
"generates": "./src/sanity/types.ts"
}
To generate the TypeScript types, simply run the following command in your terminal:
npm run typegen
After successfully executing the command, you will receive the following confirmation:
✅ TypeScript types generated for 15 schema types and 2 GROQ queries in a single file:
./src/sanity/types.ts
This version improves clarity, maintains proper headings, and ensures a consistent structure. Feel free to ask for additional changes! 😊