Skip to Content
Docs

Quickstart: Create and Run Your First Site

Create an authenticated Site, develop its application, and deploy it through a Worker.

Create an authenticated Site, run its application on a Site Worker, and deploy a visible application change. The Site holds authentication configuration; the Worker binds that Site to an application image and serves it at a browser URL.

This quickstart uses Contextual's Astro starter. If you prefer another framework, see Use Another Framework.

Before You Begin

You need:

  • A tenant with Sites and Workers enabled. You need permission to create Auth Profiles and Site Users, create and read Sites and Workers, push images, update Workers, and inspect deployments.
  • For Create repository, a connected GitHub account or organization where you can create the application's repository. In Contextual, you need read and update permissions for both the GitHub Connection (api-configuration) and the Site. Follow the GitHub Connection setup to authorize the App and review its repository access.
  • Git, Node.js 24, and Yarn for local development.
  • The Contextual CLI for local sign-in testing and deployment, and Docker with a running engine that supports linux/amd64 builds.

If Sites or Workers is missing from the console, contact Contextual support.

Set Up Authentication

Authentication is optional for Sites. This quickstart uses Managed Stytch so you can verify sign-in without supplying Stytch credentials.

Create an Auth Profile

An Auth Profile configures sign-in. Sites that share a profile use the same Site User records.

  1. In the Contextual console, open Sites > Authentication and select Create.
  2. Enter a stable ID using lowercase letters, numbers, and hyphens, a human-readable Name, and an optional Description.
  3. For Provider, select Managed Stytch.
  4. Create the Auth Profile.

For an existing Stytch project, see Choose an Authentication Provider.

Create a Site User

Create a user whose email you can access. You will use this account to verify the running Site.

  1. Open Sites > Site Users and select Create.
  2. Enter the user's Email and Name.
  3. For Role, select Member.
  4. Select the Auth Profile you created and save the Site User.

The user can sign in to Sites that use that profile. The role is available to application code; the application must enforce any role-based access rules.

Create a Site

  1. Open Sites and select Create.
  2. Enter a stable ID, such as my-site, and a display Name.
  3. Select the Auth Profile you created.
  4. Create the Site, then open it and verify the saved settings.

Keep the Site ID for the Worker's SITE_ID option. Creating this record does not start the application. See About Sites for configuration details.

Develop the Application Locally

To create the repository or download the starter from the CLI, follow Initialize Site Source with --site my-site --worker-id my-site-web to match this quickstart. To create the repository in the console, follow the steps below.

  1. Open the Site you just created and select Create repository.
  2. Select the GitHub connection for the account or organization that will own the code. Enter an available Repository name and leave Private repository selected unless you want the code to be public.
  3. Enter my-site-web in Deployed Worker ID. Choose an unused ID in your tenant. Leaving the field blank uses <site-id>-site-worker.
  4. Select Create repository and open the GitHub link. Contextual creates the repository, sets its GitHub Actions variables, and copies the Astro starter. It then uses your Site permissions to link the repository to the Site.

Clone that repository locally and create a development branch:

Terminal
git clone <repository-url>
cd <repository-directory>
git switch -c <branch-name>

If you prefer a ZIP or lack the GitHub Connection permissions, select Download source on the Site, enter a Folder name and the same Deployed Worker ID, then select Download and extract the files. This prepares the same deployment configuration without creating or linking a GitHub repository or setting Actions variables. Run the Yarn commands below in the extracted folder.

Use the Node.js version in .nvmrc and Yarn. If you use nvm, run nvm use before installing dependencies:

Terminal
yarn
yarn astro dev --host localhost

Open the local URL printed in the terminal and confirm that the starter page loads.

Stop the development server, then check the production build in Worker mode:

Terminal
DEPLOYMENT=WORKER yarn build

This selects the Astro Node adapter's standalone output. The starter Dockerfile sets the same build mode when it builds the application image.

Deploy the Site Worker

Complete the Worker CLI setup. Put ctxl and docker-credential-ctxl on PATH, select a CLI configuration for your tenant, sign in, and run ctxl workers configure-docker for the image hosts. Replace my-config below with that configuration ID.

Open contextual-deploy.env in the application root. It records the Worker ID you chose, the initial size, and the build arguments for your Site. The starter selects the latest released managed Site template at initialization. Copy its full --managed value over the placeholder below, and match the Worker ID, size, and SITE_ID to the file.

Both source options prepare the application files. To start serving the Site, create the Worker from the application root:

Terminal
ctxl workers create my-site-web \
  --size small \
  --managed 'managed-site-worker:<version-from-file>' \
  --build . \
  --option SITE_ID=my-site \
  --config-id my-config \
  --pretty

The command builds the starter Dockerfile, pushes the application image to your organization's image host, and saves the Worker configuration to start deployment. --build . supplies the template's IMAGE option. Record the Worker ID, saved configuration version, and application image reference from the response.

An unpinned SITE_ID=my-site follows the latest saved Site configuration; see Apply Site Configuration Changes.

To deploy an image built elsewhere, see Deploy an Application Image.

If you used Create repository, the repository's first Publish run already built the starter's image and published release v0.0.1. Instead of the local build above, you can create the Worker from that release with Deploy a release.

Verify Hosted Content and Sign-In

  1. In the console, select the target tenant, open Workers, and select my-site-web.
  2. Open Deployment, inspect readiness, and copy the Public Worker URL. A Running status alone does not verify the application.
  3. Open that URL in a signed-out browser session. Confirm that the protected home page redirects to sign-in.
  4. Enter the Site User's email address and complete the emailed sign-in link. Confirm that the starter home page opens.
  5. Sign out and revisit the protected page. Confirm that it requires sign-in again.

If deployment or content checks fail, see Worker Troubleshooting. Read container output with the Worker CLI logging commands.

Deploy a Visible Change

  1. Restart the local server with yarn astro dev --host localhost. In src/pages/index.astro, change the main heading to a recognizable value, such as:

    astro
    <h1>My Site Name</h1>
    
  2. Save the file and confirm the changed heading in the local browser. Stop the development server and run DEPLOYMENT=WORKER yarn build again.

  3. Review the application change. If you use a Git repository, commit the change through your normal workflow.

  4. From the application root containing the reviewed code, rebuild and deploy to the same Worker:

    Terminal
    ctxl workers update my-site-web \
      --build . \
      --config-id my-config \
      --pretty
    
  5. Record the new Worker configuration version and image reference. Inspect Deployment, allow the rollout to finish, and reopen the Public Worker URL. Confirm that the new heading appears, then repeat the sign-in and sign-out checks.

This update builds and pushes a new application image, retains the managed template and Site binding, and saves a new Worker configuration to deploy it. Pushing an image alone does not update a saved Worker. A workflow configured to deploy can both push the image and update the Worker.

For repository automation, see Deploy from GitHub. For other deployment and configuration operations, see Workers CLI Reference.