Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/(account)/billing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Free needs no card and is for personal, non-commercial projects. Enterprise plan

See [Usage](/usage) for Free allowances, shared pools, and paid usage rates.

PHP, Zero, Workers, SQL, private sharing, managed publishing, Git, CLI, API, MCP and exports are available across plans. Usage limits still apply. Connecting a domain has no extra fee. Domain registration, renewal and third-party licenses are separate purchases.
PHP, First, Workers, SQL, private sharing, managed publishing, Git, CLI, API, MCP and exports are available across plans. Usage limits still apply. Connecting a domain has no extra fee. Domain registration, renewal and third-party licenses are separate purchases.

Domains registered through Spacefast or WordPress.com, and domains using Spacefast DNS, do not count toward the Free plan's {{free-customDomains}}-domain allowance. Other connected domains and individually connected subdomains count toward it. Managed HTTPS is included. Wildcards such as `*.example.com` require Plus or Enterprise.

Expand Down
6 changes: 3 additions & 3 deletions content/(account)/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ These are per team each month, except storage, which is a retained-byte allowanc

<include>/_pricing/usage.md</include>

The CPU allowance combines PHP, Zero and SQL. Each other allowance stands on its own; unused build minutes cannot buy more transfer. Free has no dollar credit and no automatic overage bill.
The CPU allowance combines PHP, First and SQL. Each other allowance stands on its own; unused build minutes cannot buy more transfer. Free has no dollar credit and no automatic overage bill.

Exceeding an allowance alerts Spacefast for review. A Space may be suspended until the applicable allowance resets, retained storage falls below its limit, or the team upgrades. Data stays and exports remain available.

Expand All @@ -23,9 +23,9 @@ Prices are USD before tax. The included quantities below belong to the whole tea

CPU means active processing time, excluding waits. There is no memory charge. Build minutes measure elapsed machine time, including installation and idle time; platform-caused retries are not billed.

An invocation is one PHP or Zero origin execution, including a request that bypasses the cache or cron run. Cached hits and Worker requests are excluded. Workers have their own request meter.
An invocation is one PHP or First origin execution, including a request that bypasses the cache or cron run. Cached hits and Worker requests are excluded. Workers have their own request meter.

Cached delivery counts cached response bytes. Non-cached transfer counts origin misses, bypasses and PHP or Zero response bytes. Worker responses are excluded from that transfer charge. Bytes are counted once on the path that produced them.
Cached delivery counts cached response bytes. Non-cached transfer counts origin misses, bypasses and PHP or First response bytes. Worker responses are excluded from that transfer charge. Bytes are counted once on the path that produced them.

Email counts recipient deliveries, so one message to three people counts as three. Daily delivery safeguards still apply. A credit balance does not override them; check the current entitlement before sending.

Expand Down
2 changes: 1 addition & 1 deletion content/(dynamic)/crons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ There's no dashboard editor for crons. Declare schedules in `sf.jsonc`, then pub

## How a run happens

A cron is a scheduled `GET` against a path on your own site. It goes through the same front door a visitor gets, so whatever serves that path answers it: a [Zero](/zero) page, a [Functions](/functions) route, or a static file.
A cron is a scheduled `GET` against a path on your own site. It goes through the same front door a visitor gets, so whatever serves that path answers it: a [First](/first) page, a [Functions](/functions) route, or a static file.

A response under 400 is a success and is silent. A response of 400 or worse, or a fatal error, is a failure and is reported.

Expand Down
24 changes: 12 additions & 12 deletions content/(dynamic)/database.mdx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
---
title: Database
description: Every Space gets its own MySQL. A Zero app's collections and tables live there, Spacefast migrates it on publish, and a single-use SQL console opens it when you need raw SQL.
description: Every Space gets its own MySQL. A First app's collections and tables live there, Spacefast migrates it on publish, and a single-use SQL console opens it when you need raw SQL.
sidebar:
order: 2
---

There's no connection string for this database. Your code reaches it through Zero's `db` or a worker's `env.DB`, and you reach it through a single-use SQL console.
There's no connection string for this database. Your code reaches it through First's `db` or a worker's `env.DB`, and you reach it through a single-use SQL console.

:::note[Don't have a database yet?]
Start a [Zero](/zero) app with `sf init --runtime zero`. Its `zero.config.ts` declares the collections and tables, and Spacefast creates them when you publish. A [Functions](/functions#what-is-on-env) worker also gets the database, through `env.DB`.
Start a [First](/first) app with `sf init --runtime first`. Its `first.config.ts` declares the collections and tables, and Spacefast creates them when you publish. A [Functions](/functions#what-is-on-env) worker also gets the database, through `env.DB`.
:::

## What it is

Every Space has one database, the MySQL that lives on the machine serving the site. A [Zero](/zero) app keeps its collections and tables there. A [Functions](/functions) worker gets it as `env.DB`.
Every Space has one database, the MySQL that lives on the machine serving the site. A [First](/first) app keeps its collections and tables there. A [Functions](/functions) worker gets it as `env.DB`.

You do not create it, size it, or connect to it. Your config declares the schema, and Spacefast applies it when a version initializes.

:::warning[There is no external connection string]
No route, flag, or dashboard field returns a DSN. Your code reaches the database through `db` (Zero) or `env.DB` (Functions). For everything else there is the [SQL console](#the-sql-console).
No route, flag, or dashboard field returns a DSN. Your code reaches the database through `db` (First) or `env.DB` (Functions). For everything else there is the [SQL console](#the-sql-console).
:::

## Query it from code

In a Zero app, hooks and actions read and write through `db`. Your schema is the API, and its column and relation names are checked at build time.
In a First app, hooks and actions read and write through `db`. Your schema is the API, and its column and relation names are checked at build time.

```ts zero.config.ts
import { action, db, defineConfig, HttpError, integer, table, text } from "zero";
```ts first.config.ts
import { action, db, defineConfig, HttpError, integer, table, text } from "first";

// Each signed-in account reads and writes only its own rows, through every route.
const notes = table(
Expand Down Expand Up @@ -99,12 +99,12 @@ export default {

## Migrations

Your `zero.config.ts` is the schema. When you publish a version that changes it, Spacefast diffs it against the schema the Space already runs and applies the difference while the new version initializes, before it can go live.
Your `first.config.ts` is the schema. When you publish a version that changes it, Spacefast diffs it against the schema the Space already runs and applies the difference while the new version initializes, before it can go live.

To see the SQL a change produces, build locally and read the newest file in `zero/migrations/`:
To see the SQL a change produces, build locally and read the newest file in `first/_generated/migrations/`:

```bash
sf zero build
sf first build
```

:::warning[Rollback does not roll back the schema]
Expand All @@ -130,7 +130,7 @@ sf db console --show-secret

`sf db console` opens a browser by default, because the URL grants full SQL authority over the Space's database. `--show-secret` prints it instead, and is the deliberate override. The URL is masked in `--json` receipts unless you pass it. Opening the console needs write access to the Space.

A Zero app's tables share a prefix that starts with `sfz_`.
A First app's tables share a prefix that starts with `sfz_`.

## Limits

Expand Down
8 changes: 4 additions & 4 deletions content/(dynamic)/environment-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ EOF
sf publish
```

A [Zero](/zero) action or hook reads it with `env()`, which returns `null` for a name that isn't set.
A [First](/first) action or hook reads it with `env()`, which returns `null` for a name that isn't set.

```ts zero.config.ts
import { action, defineConfig, env } from "zero";
```ts first.config.ts
import { action, defineConfig, env } from "first";

export default defineConfig({
actions: {
Expand All @@ -109,7 +109,7 @@ export default defineConfig({
});
```

A Zero app sees **Space** variables only. Team variables do not reach it, so set what the app needs on the Space.
A First app sees **Space** variables only. Team variables do not reach it, so set what the app needs on the Space.

A [Functions](/functions) worker reads the same values from `env`, its second handler argument.

Expand Down
Loading
Loading