Back to articles
Stop Writing Strapi Types by Hand — Auto-Generate a Fully Typed Client in Seconds

Stop Writing Strapi Types by Hand — Auto-Generate a Fully Typed Client in Seconds

via Dev.to WebdevDearonski

If you're using Strapi v5 with TypeScript, you've probably spent hours writing interfaces to match your content types. And every time you change a field in Strapi — you update the types manually. Again. I built strapi-typed-client to solve this. It's a Strapi plugin + CLI that reads your schema and generates clean TypeScript types and a fully typed API client. One command, full autocomplete. The problem Strapi generates contentTypes.d.ts internally, but it's full of Schema.Attribute.* generics that are unusable on the frontend. You end up writing something like: // Writing this by hand for every content type... interface Article { id : number title : string content : string category ?: Category // did I forget a field? who knows } And then building fetch wrappers with zero type safety: const res = await fetch ( ` ${ STRAPI_URL } /api/articles?populate=*` ) const data = await res . json () // data is `any` — good luck The solution Install the package in your Strapi project: npm install

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles