# stop-server

Learn how to stop a running server.

This action stops a server previously started by [`start-server`](/reference/cli/templates/actions/start-server).

The server is identified by the ID stored in the result of the start-server action.

## Example

The following template starts a server and stops it after the user presses a key:

**template.json5**

```json5
{
  "$schema": "https://schema.croct.com/json/v1/template.json",
  "title": "Server lifecycle",
  "description": "Starts and stops a development server.",
  "actions": [
    {
      "name": "start-server",
      "result": {
        "id": "serverId"
      }
    },
    {
      "name": "prompt",
      "type": "keypress",
      "message": "Press any key to stop the server"
    },
    {
      "name": "stop-server",
      "id": "${this.serverId}"
    }
  ]
}
```

To apply this template, run:

```sh
croct use template.json5
```

## Properties

These are the supported properties:

- `name`: `string`

  The action identifier. Always `stop-server` for this action.

- `id`: `string`

  The ID of the server to stop.

  This is the value stored by the [`start-server`](/reference/cli/templates/actions/start-server) action's [`result.id`](/reference/cli/templates/actions/start-server#result-id-prop) property.

## Explore

- [Start server](/reference/cli/templates/actions/start-server): Learn how to start a development server.
- [Open link](/reference/cli/templates/actions/open-link): Learn how to open the server URL in a browser.
