start-server
Learn how to start a development server.
This action starts a development server and waits until it is ready before continuing to the next action.
When no configuration is provided, the action auto-detects the server script and URL from the project. Use stop-server to shut it down when done.
Example
The following template starts the server and opens it in the browser:
{ "$schema": "https://schema.croct.com/json/v1/template.json", "title": "Live preview", "description": "Starts the server and opens a preview.", "actions": [ { "name": "install" }, { "name": "start-server", "server": { "script": "dev", "url": "http://localhost:3000" }, "result": { "id": "serverId", "url": "serverUrl" } }, { "name": "open-link", "url": "${this.serverUrl}" }, { "name": "prompt", "type": "keypress", "message": "Press any key to stop the server" }, { "name": "stop-server", "id": "${this.serverId}" } ]}To apply this template, run:
npx croct@latest use template.json5Properties
These are the supported properties:
- namestring
The action identifier. Always start-server for this action.
- server(optional)object
The server configuration.
When omitted, the action auto-detects the script and URL from the project's configuration.
- result(optional)object
Variable names to store the server information.
- id(optional)string
The variable name to store the server ID.
Use this ID with stop-server to shut down the server. The value is null if the server was already running before this action.
- url(optional)string
The variable name to store the server URL.
- id(optional)