Overview
Learn about the template format and how templates work.
Templates are JSON5 files that automate project setup and configuration. A template declares options for user input, then runs a sequence of actions that can install dependencies, create resources, download files, prompt the user, and more.
Example
Here is a template that checks for a framework, installs dependencies, and prints a confirmation:
template.json5
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Quick start", "description": "Sets up the project with the Croct SDK.", "options": { "typescript": { "type": "boolean", "description": "Whether to use TypeScript.", "default": true } }, "actions": [ { "name": "check-dependency", "dependencies": [ { "name": "next" } ] }, { "name": "install" }, { "name": "integrate-croct" }, { "name": "print", "semantics": "success", "message": "You're all set!" } ]}To apply this template, run:
npm
npx croct@latest use template.json5For the full list of top-level properties, see the template file reference.
Concepts
- Options are typed parameters the template accepts as input. The CLI prompts for any required options not provided via flags.
- Expressions are dynamic values using the ${...} syntax, with access to variables, functions, and operators.
- Actions are the steps a template performs, from installing dependencies to creating files. See the action reference for the full list.
Sources
Templates can be loaded from local files, URLs, npm packages, and registries:
npm
npx croct@latest use croct://starter/nextjsSee sources for all supported formats.
Publishing
To scaffold a new template, use the create template command. For details on sharing templates, see the publishing templates tutorial.