# Hosting, starters and the Deploy button

> A working app on Hosting in two minutes from a starter, and a "Deploy to Infaris" button for your own repository.

Source: https://docs.infaris.com/en/pulseguard/hosting-starters

A starter is a ready app with an `infaris.toml` that names everything it needs from Hosting: tables, policies,
buckets, functions and crons. One command copies it, creates all of it and publishes it.

```bash
npx @infaris/guard-cli hosting templates list
npx @infaris/guard-cli hosting init --template nextjs-saas my-saas
```

| Template | What you get | Runs on |
| --- | --- | --- |
| `nextjs-saas` | Sign-in with a code (OTP), organisations, RLS per organisation, a billing placeholder without Stripe, a private bucket, a function with a nightly cron | Vercel |
| `astro-site` | An Astro blog or site from Markdown, a private bucket for media | Cloudflare |
| `nuxt-app` | Nuxt with sign-in and private notes per user through the Data API | Cloudflare |
| `laravel-app` | Laravel with the managed Postgres database (`DATABASE_URL`) and a generated `APP_KEY` | Infaris Cloud |
| `ai-chat` | A chat that answers from your own documents: pgvector and the AI Gateway (EU providers only) | Vercel |
| `realtime-todo` | The quickstart: todos with RLS, Realtime, storage, a function and a cron | Vercel |
| `static-site` | HTML and CSS without a build step | Cloudflare |

## What `init` does

1. Copies the starter into a new folder (never into a folder with other files) and gives it your project name. If a
   later step fails, the same command goes on in that folder without copying again.
2. Creates the site on a free Infaris address (or `--domain`) and links the folder to it (`.infaris/hosting.json`).
3. Creates the Auth project (`[auth]`), sign-up by invitation; organisations when the file says `orgs`.
4. Creates the managed database (`[db]`) and its extensions (`vector` for the AI chat), switches on the Data API with
   the Auth project, then runs `db/migrations` and applies the policies and exposed tables.
5. Creates buckets, functions (private, with the Auth project) and crons, and deploys the function code.
6. Sets the variables: the bucket's key, the addresses of the Data API, Realtime and functions, generated secrets
   such as Laravel's `APP_KEY`, and an AI Gateway linked to the site.
7. Runs the first deploy with `hosting up` and prints the address.

Every starter starts closed: Row Level Security on every table, nothing exposed to `anon`, private buckets and
functions, sign-up by invitation. Invite yourself afterwards:
`infaris-guard hosting auth users invite <project> --email you@company.com`.

| Flag | What |
| --- | --- |
| `--dry-run` | Shows what would be created; changes nothing. |
| `--no-deploy` | Creates everything but stops before the first deploy; run `hosting up` later. |
| `--name <name>` | The project name (default: the folder name). |
| `--domain <host>` | A hostname of your own, or a label under the Infaris address. |
| `--yes` | Needed only when the template opens sign-up for everyone. |
| `--json` | One JSON document with the ids and the address. |

When a bucket or function name is already taken in your organisation, `init` picks a free one and writes it into
`infaris.toml`; it never takes over another app's resource. Later changes go through `hosting dev push` (the same
file) and `hosting up`.

## What goes online

A static site only publishes its output folder (`public/`, `dist/`, `out/`, `.output/public`). Repository and config
files never go online, also when the output is the project folder itself: `infaris.toml`, `README*`, `LICENSE*`,
`CHANGELOG*`, lockfiles (`package-lock.json`, `bun.lock`, `yarn.lock`, `pnpm-lock.yaml`, `composer.lock`, ...), and at
the top `package.json`, `tsconfig.json`, `Dockerfile` and `docker-compose.yml`. Dot-files (`.env*`, `.git*`) never go
either. `hosting up` names what it left out before the upload.

Put more in an `.infarisignore` (gitignore syntax) in the project or the output folder; `!` takes a default back:

```
drafts/
*.psd
!README.md
```

An app built on a server (a Dockerfile) keeps its manifests and lockfiles, since the build needs them;
`.infarisignore` applies there too.

## Your own repository as a template

`--template owner/repo` clones a GitHub repository with an `infaris.toml` and does the same. In the `[site]` section
of the file:

```toml
[site]
platform = "vercel"      # cloudflare, vercel or server (Infaris Cloud)
database = true          # a managed Postgres database as DATABASE_URL, also without [db]
ai = true                # an AI Gateway linked to the site

[site.generate]
APP_KEY = "laravel-key"  # or "secret": 32 random bytes, stored once as a secret variable
```

## The "Deploy to Infaris" button

Put this in the README of a repository:

```markdown
[![Deploy to Infaris](https://app.infaris.com/deploy/button.svg)](https://app.infaris.com/deploy?repo=owner/repo)
```

Whoever clicks it signs in to Infaris (or creates an account), lands on Hosting > New project, sees the steps and
continues to "Put a project online": Hosting reads the repository, offers the platforms that can run it, creates the
site, connects the repository and runs the first deploy. The link carries only `repo` (or `template`); anything else
is dropped. Guard makes the Markdown for you on the New project page.
