Sharing Strapi schema with other projects (e.g. front-ends)

From my experience the Strapi schemas cannot currently be shared with the frontend. This has the following reasons:

  • Strapi is written in JavaScript and features no static typing
  • Strapi schemas are defined as JSON with a proprietary structure which AFAIK is essentially useless for statically typed clients written in e.g. TypeScript
  • TypeScript support with Strapi itself is not matured enough yet:
    • It is currently an afterthought because the whole architecture and ecosystem is not written with TypeScript in mind
    • The ts:generate-types command generates a huge file which contains very complicated typings and stuff that is irrelevant for the client
    • (I know that improving TS support is in Strapi’s backlog)
  • The flexibility of the REST API is both a blessing and a curse: Because of Population & Field Selection query params the response structure can differ dramatically depending on what you populate and which fields you select
    • The flexibility is similar to using GraphQL with the same benefits and drawbacks

So to answer your question:

4 - Do everything manually, for now

Yes currently it’s this manual work I’m afraid.

1 Like