TinaCMS provides built-in search functionality for content. This is useful for allowing editors to quickly finding content in a site. TinaCloud's content search is powered by Fergus McDowall's search-index library.
Note: Search is not currently supported in self-hosted Tina.
To enable search functionality, you will need to populate the search field in your Tina configuration. The only required element of the search configuration when using TinaCloud search is the search.tina.indexerToken field. This can be obtained from the TinaCloud dashboard for the project.
export default defineConfig({//...schema: {collections: [// Array of collections],},search: {tina: {indexerToken: '<Your Search Token>',stopwordLanguages: ['eng'],},indexBatchSize: 100,maxSearchIndexFieldLength: 100,},//.. Other config})
Property | Description |
|---|---|
| TinaCloud search token (required) |
| Optional array of string stopword languages. Defaults to |
| Enable or disable fuzzy search globally. Defaults to |
| Maximum edit distance for fuzzy matching (0-10). Higher values find more distant matches but may return less relevant results. Defaults to |
| Minimum similarity score (0-1) required for a match. Higher values return more precise matches. Defaults to |
| Maximum number of similar terms to consider per search word (1-100). Defaults to |
| Allow character transpositions (e.g., "teh" → "the") using Damerau-Levenshtein algorithm. Defaults to |
| Used by the indexing process to determine the number of documents to index per request. Defaults to |
| For variable length text fields, this controls how much of the text is considered when indexing. A higher value will increase the indexing time and size of the search index. Defaults to |
When search is configured and a site is running locally with the dev command, content will be automatically indexed at startup. Any changes to local content will also trigger updates to the (local) search index.
When search is configured and a site is being built for production using the build command, the search index will be automatically created and uploaded to TinaCloud. Each Git branch for your site has a separate search index.
Note that the search index is "live" once the site is built, so any newly added or removed content may be reflected in the search index before the site has been deployed. Building the search index can be skipped by passing the --skip-search-index cli option to the build command. Then the search-index command can be run separately once the site deployment completes.
By default, all collection field types (except image) are including in the search index. You can improve discoverability of content by controlling which fields are included in the search index. This is done by setting the optional searchable property on fields in the collection schema. For example, to disable indexing for an author field, use something like:
// ...fields: [// ...{label: 'Author',name: 'author',type: 'reference',collections: ['author'],searchable: false, // Disable indexing of the author field},]//
By default, only the first 100 characters of a text field are used when building the search index. This can be adjusted globally in the search configuration (see above), but can also be done on a per field basis like so:
// ...fields: [// ...{label: 'Post Body',name: 'body',type: 'string',maxSearchIndexFieldLength: 50, // Only index the first 50 characters of this field},]//
TinaCMS includes built-in fuzzy search capabilities that help users find content even when they make typos or spelling mistakes. Fuzzy search is enabled by default, so your search will automatically handle common misspellings without any additional configuration.
Fuzzy search was released in tinacms@3.3.0 and @tinacms/cli@2.1.0. No config changes are needed to get the benefits of the new search — just update your packages!
Fuzzy search finds terms in your content that are "similar" to what the user typed, even if they don't match exactly. TinaCMS uses the Damerau-Levenshtein distance algorithm, which measures similarity by counting the minimum number of single-character edits needed to transform one word into another.
Supported edit operations:
Operation | Example | Edits |
|---|---|---|
Insertion | "rect" → "react" | 1 |
Deletion | "reactt" → "react" | 1 |
Substitution | "reect" → "react" | 1 |
Transposition | "raect" → "react" | 1 (swapping adjacent characters) |
When a user searches, each word in their query is expanded to include similar terms from your indexed content. For example, searching "Raect tutrial" would also match documents containing "React tutorial".
Fuzzy search works out of the box with sensible defaults. You can customize its behavior by adding fuzzyOptions to your search configuration:
export default defineConfig({//...search: {tina: {indexerToken: '<Your Search Token>',stopwordLanguages: ['eng'],fuzzyEnabled: true, // enabled by defaultfuzzyOptions: {maxDistance: 2, // max edit distance (0-10)minSimilarity: 0.6, // min similarity score (0-1)maxTermExpansions: 10, // max similar terms per worduseTranspositions: true, // allow letter swaps},},},//...})
Here are examples of typos that fuzzy search will catch with the default settings:
// Single character errors"Raect" → matches "React""TypeScrpt" → matches "TypeScript""Javscript" → matches "JavaScript"// Transposed letters"teh" → matches "the""freind" → matches "friend"// Multi-word queries with typos"Raect tutrial" → matches "React tutorial""TypeScrpt developmnt" → matches "TypeScript development"
If you prefer exact matching only, you can disable fuzzy search:
export default defineConfig({//...search: {tina: {indexerToken: '<Your Search Token>',fuzzyEnabled: false, // Disable fuzzy search},},//...})
Fuzzy search includes automatic caching for repeated queries. If you need to optimize performance further, consider these adjustments:
Adjustment | Effect |
|---|---|
Lower | Faster searches, fewer false positives, but may miss some typos |
Higher | More precise matches, fewer irrelevant results |
Lower | Faster searches with large indexes |
Example configuration for stricter, faster matching:
fuzzyOptions: {maxDistance: 1, // Only 1 edit allowedminSimilarity: 0.8, // 80% similarity requiredmaxTermExpansions: 5, // Fewer term expansions}
Issue | Solution |
|---|---|
Search returns too many irrelevant results | Increase |
Search doesn't find results with typos | Ensure |
Search feels slow | Reduce |
Want exact matching only | Set |
Currently only TinaCloud's search API is supported but we plan to provide alternative providers in the near future, as well as documentation for implementing custom search providers. If you'd like support for a specific search provider, let us know.