# Deployment and website embedding

## Deploy to shinyapps.io

Authenticate once with the token commands supplied by your shinyapps.io account, then run the following from R:

```r
rsconnect::deployApp(
  appDir = ".",
  appName = "cascade-simulation-results",
  appTitle = "Cascade Simulation Results Explorer"
)
```

The deployment bundle should be this app directory only. Do not deploy the surrounding manuscript workspace.

## Deploy to Posit Connect

After configuring your Connect account in `rsconnect`, run:

```r
rsconnect::deployApp(
  appDir = ".",
  appName = "cascade-simulation-results"
)
```

For a self-managed server, copy the entire directory beneath the Shiny Server application root and ensure the runtime dependencies listed in `DESCRIPTION` are installed.

## Link from the manuscript or website

After deployment, the app's **Copy view link** control produces a URL that restores the current panel and condition filters. A generic manuscript sentence is provided in `MANUSCRIPT_LINK_TEXT.md`.

To embed the deployed application in a webpage, replace the example URL below:

```html
<iframe
  src="https://YOUR-HOST.example/cascade-simulation-results/"
  title="Cascade Simulation Results Explorer"
  width="100%"
  height="1050"
  loading="lazy"
  style="border: 0;"
></iframe>
```

The host must permit iframe embedding. If it does not, use an ordinary hyperlink instead.

## Predeployment checks

From the app directory:

```sh
Rscript prepare_app_data.R
Rscript tests/run_tests.R
```

Then start the app locally and inspect at least one sensitive, moderate, elevated, and resilient condition. In particular, confirm that Elevated and Resilient conditional-step cells report no complete cascades rather than zero completion time.

