Skip to content

CLI ​

text
strapi-client generate (--config [file] | --dir <path> | --url <baseURL> | --openapi <spec> | --graphql <url>) [options]

The binary is strapi-client. npx @fbritoferreira/strapi generate runs it. It is published on npm, not JSR.

Exactly one source, or --config for every section of a config file.

Sources ​

FlagReadsWrites
--dir <path>src/api/**/schema.json and src/components/**/*.json in a Strapi projectStrapiContentTypes / StrapiSingleTypes
--url <baseURL>Content-Type Builder on a running instance, after POST /admin/loginsame
--openapi <spec>An OpenAPI JSON file or URL, or a documentation-plugin pageStrapiRoutes
--graphql <url>Introspection of a GraphQL endpointschema types and strapiGraphqlArgs
--config [file]Every section of a config fileone file per section

Options ​

FlagEnvironment variableMeaning
--emailSTRAPI_ADMIN_EMAILAdmin email for --url
--passwordSTRAPI_ADMIN_PASSWORD for --url, STRAPI_DOCS_PASSWORD for a restricted OpenAPI page
--tokenSTRAPI_TOKENBearer token for --openapi URLs and --graphql
-o, --output <file>Output file. Default strapi-types.ts, strapi-routes.ts, or strapi-graphql.ts
--include-pluginsAlso emit plugin content types. api::* only by default
--checkExit 1 if the output is missing or out of date. Writes nothing. Cannot be combined with --watch
--watchGenerate, then regenerate as the source changes. Stop with Ctrl-C
--interval <ms>Poll period for a URL source under --watch. Default 2000. Overrides watch.interval
-h, --helpPrint usage

--config with no path looks for strapi-codegen.config.ts, .mts, .js, .mjs, then .json in the current directory.

Exit code 0 means every requested file was written or already up to date. Exit code 1 means a source failed, a --check file was stale, or the arguments were invalid. Under --config, one failing section does not skip the others; the summary line is N of M generated.

Released under the MIT License.