Skip to content
TypeScript
2.5 KB
Raw Blame
---
title: SolidStart
description: Deploy a SolidStart app to Cloud Run with GCP.Website.SolidStart — SSR in a container, prerendered pages served as static files.
sidebar:
  order: 17
---

import PackageManagers from "../../../../components/PackageManagers.astro";

export const devDeps = "@alchemy.run/frontend-frameworks";

`GCP.Website.SolidStart` deploys a [SolidStart](https://start.solidjs.com)
app to Cloud Run. The server renders pages in the container, and
prerendered pages are served as static files.

## Install

The build integration ships separately. It only runs at deploy time,
so a dev dependency is enough:

<PackageManagers dev={devDeps} />

Docker has to be running when you deploy. The image is built on your
machine.

## Deploy the site

```typescript
// alchemy.run.ts
import * as Alchemy from "alchemy";
import * as GCP from "@alchemy.run/gcp";
import * as Effect from "effect/Effect";

export const Website = GCP.Website.SolidStart("Website");

export default Alchemy.Stack(
  "MySite",
  { providers: GCP.providers(), state: GCP.state() },
  Effect.gen(function* () {
    const site = yield* Website;
    return { url: site.url };
  }),
);
```

Run `alchemy deploy`. `site.url` is the Cloud Run service URL.

## Pass environment variables

```diff lang="typescript"
// alchemy.run.ts
-export const Website = GCP.Website.SolidStart("Website");
+export const Website = GCP.Website.SolidStart("Website", {
+  env: {
+    GREETING: "Hello from Cloud Run!",
+  },
+});
```

Server code reads the value from `process.env.GREETING`.

## Prerender routes

Alchemy adds the nitro plugin to your build, so nitro options go on
the `nitro` prop. Remove `nitroV2Plugin()` from `vite.config.*`:

```typescript
export const Website = GCP.Website.SolidStart("Website", {
  nitro: { prerender: { routes: ["/", "/about"] } },
});
```

## Tune Cloud Run

```typescript
export const Website = GCP.Website.SolidStart("Website", {
  scaling: { minInstanceCount: 1 },
  resources: { limits: { cpu: "1", memory: "1Gi" } },
});
```

One warm instance means no cold start for the first visitor. See
[Websites](/gcp/frontend/websites#tune-cloud-run) for the other
settings.

## Local development

`alchemy dev` runs the framework's dev server with hot reload and
creates nothing in the cloud. Wrap the site in `Alchemy.remote()` to
deploy it for real during dev.

## Where next

- [Websites](/gcp/frontend/websites) — the settings every site shares.
- [Website reference](/providers/gcp/website#solidstart) — every prop.