# About Sites

These instructions apply to the current Admin Console.

{% hint style="info" %}
Contextual Sites run on Contextual Workers, which are in early access and may not be available in your account. [Contact Contextual support](mailto:help@contextual.io) to request that Workers be enabled for your tenant.
{% endhint %}

Create, edit, and delete Sites in the Contextual console.

## How Sites Work

A Site holds the application's identity and optional authentication configuration. Its source code and deployment are managed separately; see [Parts of a Site](https://docs.contextual.io/build/sites.md#parts-of-a-site).

Creating a Site does not start a running application. To serve it, configure a [Site Worker](https://docs.contextual.io/build/sites/site-workers.md) with the Site ID and application image.

Saving changes to a Site creates a new configuration version. How a running Site Worker picks up those changes depends on whether its Site binding is [pinned to a version](#apply-site-configuration-changes).

An [Auth Profile](https://docs.contextual.io/build/sites/manage-auth-profiles.md) is optional. When a Site references one, the Site Worker validates sessions and resolves Site Users associated with that profile. The application controls which routes require sign-in and what each user may access. Without an Auth Profile, the standard runtime does not require users to sign in.

## Create a Site

{% hint style="info" %}
For an authenticated Site, first [create an Auth Profile](https://docs.contextual.io/build/sites/manage-auth-profiles.md#create-an-auth-profile). To test sign-in with an account you control, [create a Site User](https://docs.contextual.io/build/sites/manage-site-users.md#create-and-connect-a-site-user) whose email you can access.
{% endhint %}

1. Open **Sites** and select **Create**.
2. Enter the **ID** and **Name**.
3. Select the **Auth Profile** that the running Site should use. Leave it unset for a public Site that does not use Site authentication.
4. If you use BYO Stytch and have a separate profile for local development, select it under **Test Auth Profile**.
5. Create the Site, then open it and verify its saved settings.

Keep the Site ID for the Site Worker's `SITE_ID` option. You can bring your own application image or [initialize the Astro starter](https://docs.contextual.io/build/sites/quickstart.md#develop-the-application-locally) from the saved Site.

## Edit a Site

1. Open **Sites** and select the Site in the intended tenant.
2. Open its edit form.
3. Update **Name**, **Auth Profile**, or **Test Auth Profile** as needed. **ID** is read-only.
4. Save the changes and verify the saved values.
5. Complete the follow-up action for the setting you changed:

| Change | Follow-Up Action |
| --- | --- |
| Change **Name**. | Check the display name in the console. |
| Add, replace, or remove **Auth Profile**. | Follow [Apply Site Configuration Changes](#apply-site-configuration-changes) for the Worker binding, Managed Stytch origin registration, and hosted access checks. Removing the profile removes the standard runtime sign-in requirement after the new configuration loads. |
| Change **Test Auth Profile**. | Follow [Configure BYO Stytch for Production and Local Development](https://docs.contextual.io/build/sites/manage-auth-profiles.md#configure-byo-stytch-for-production-and-local-development) to copy the intended profile's configuration into `site-auth.local.json`, which Git ignores, and test it. Saving the selection does not configure your local server. |

When changing from BYO Stytch to Managed Stytch, or removing the primary profile, the edit form clears the separate **Test Auth Profile** selection. Review the saved authentication settings after this change.

To deploy application code, build a new application image and update the Site Worker. See [Deploy and Update](https://docs.contextual.io/build/sites/releases.md). Editing the Site does not change the Worker's image.

### Apply Site Configuration Changes

A hosted Site Worker reads its Site and authentication configuration at startup and refreshes it about every minute. The `SITE_ID` option controls which Site configuration it reads:

| Site Binding | How Site Changes Apply |
| --- | --- |
| An unpinned ID, such as `SITE_ID=my-site` | Follows the latest saved Site record. Changes such as selecting a different Auth Profile are picked up on refresh. |
| An ID pinned to a version, such as `SITE_ID=my-site#<version>` | Keeps that saved Site version. To apply Site edits, update the Worker's binding to the new Site version or use an unpinned ID. |

The referenced Auth Profile's settings refresh about every minute in either case, including when the Site version is pinned.

If you add Managed Stytch to a running Site that had no authentication, or switch it from BYO to Managed Stytch, restart or update each Worker serving the changed Site version. This registers its browser origins and sign-in redirects with Managed Stytch. After any hosted authentication change, allow time for the configuration to load, then verify sign-in, sign-out, and access to protected routes at the Worker URL and any custom domain.

Local development with the Astro application uses `site-auth.local.json` instead. Follow [Use an Auth Profile During Local Development](https://docs.contextual.io/build/sites/manage-auth-profiles.md#use-an-auth-profile-during-local-development) to refresh that file.

## Delete a Site

{% hint style="warning" %}
Before deleting a Site, stop or reconfigure any Worker whose `SITE_ID` names it. A Worker with that binding depends on the Site to load its configuration.
{% endhint %}

Open **Sites**, select the Site in the intended tenant, and delete it from the console. Verify that you are removing the intended Site record before confirming. GitHub repositories stay in place when you delete a Site, including repositories created for older Sites.
