
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood question! In Sanity, you can use .js, .jsx, .ts, or .tsx for schema files, and the choice mostly comes down to whether you're using TypeScript and personal/team preference. There's no strict requirement to use one over the other for "dynamic" vs "static" schemas.
Here's the practical breakdown:
Use .ts or .tsx if:
defineType and defineField that provide better TypeScript inferenceUse .js or .jsx if:
Regarding .jsx vs .tsx specifically:
The .jsx/.tsx extensions are technically for files containing JSX syntax (React components). Schema files are typically just JavaScript/TypeScript objects, so they don't need the x suffix. However, many projects use .tsx for all TypeScript files as a convention, and it works fine.
Best practice recommendation:
.ts for schema files (or .tsx if that's your project convention).js for schema filesThe schema-as-code approach in Sanity treats all schemas as code files, and the extension doesn't change how Sanity processes them. What matters more is consistency across your project.
Example with TypeScript (recommended for type safety):
// schemas/product.ts
import { defineType, defineField } from 'sanity'
export default defineType({
name: 'product',
type: 'document',
fields: [
defineField({
name: 'title',
type: 'string'
})
]
})The main advantage of TypeScript is that you can leverage Sanity TypeGen to generate types from your schemas, giving you end-to-end type safety from content model to query results.
TL;DR: Use .ts for TypeScript projects, .js for JavaScript projects. The "dynamic" nature of a schema doesn't change which extension to use—consistency across your codebase matters more.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store