> ## Documentation Index
> Fetch the complete documentation index at: https://getfloo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a Shopify app on floo

> Deploy an embedded Shopify admin app with managed Postgres sessions, webhooks, and a URL Shopify admin can frame.

An embedded Shopify app on floo: it opens inside Shopify admin, signs merchants in with Shopify, keeps their sessions in managed Postgres, and receives webhooks at `https://<app>.getfloo.app`.

Start from [getfloo/shopify-app-template](https://github.com/getfloo/shopify-app-template). It is Shopify's [React Router app template](https://github.com/Shopify/shopify-app-template-react-router) with Postgres in place of SQLite and a `floo.app.toml`. You also need a [Shopify Partner account](https://www.shopify.com/partners), a development store, and the [Shopify CLI](https://shopify.dev/docs/apps/tools/cli).

## Set up your agent

```bash theme={null}
curl -fsSL https://getfloo.com/install.sh | bash
floo auth login
```

For Claude Code, also run `floo skills install --path .claude/skills/floo`. Cursor, Codex, and other agents: [Agent setup](https://getfloo.com/docs/guides/agent-setup.md).

## Agent prompt

Click **Use this template** on the template's GitHub page, clone your copy, then paste this into your agent. Replace `storefront-app` with your app name.

```text theme={null}
Deploy this Shopify app to floo. App name: storefront-app.
1. Set name = "storefront-app" under [app] in floo.app.toml and commit.
2. Run `npm install`, then have me run `shopify app config link` to create or pick the Shopify app. Wait for me.
3. Run `floo deploy --json`. The first deploy stops on SHOPIFY_API_KEY, SHOPIFY_API_SECRET and SCOPES.
4. Have me run `floo env set SHOPIFY_API_KEY --stdin` and `floo env set SHOPIFY_API_SECRET --stdin` and paste the client ID and secret from the Shopify Dev Dashboard. Never ask me to paste them to you.
5. Run `floo env set SCOPES=write_products`, using the `scopes` value from shopify.app.toml, then `floo deploy --rebuild --json`.
6. Set application_url in shopify.app.toml to the dev URL, and redirect_urls under [auth] to the dev URL plus /auth/callback. Commit, then have me run `shopify app deploy`.
7. Report the dev URL and tell me to install the app on my development store from the Dev Dashboard.
```

## floo.app.toml

```toml floo.app.toml theme={null}
[app]
name = "storefront-app"
access_mode = "public"

[services.web]
type = "web"
path = "."
port = 3000
ingress = "public"
migrate_command = "npx prisma migrate deploy"

[services.web.env]
managed = ["postgres"]
required = ["SHOPIFY_API_KEY", "SHOPIFY_API_SECRET", "SCOPES"]

[managed.default]
type = "postgres"
```

* `access_mode = "public"`: Shopify authenticates every request itself. The embedded admin sends a session token, and webhooks carry an HMAC signature that `authenticate.webhook` checks. floo's [sign-in](https://getfloo.com/docs/guides/app-auth.md) would block both, so leave the app public and let Shopify's checks gate it.
* `migrate_command` creates Prisma's `Session` table once per deploy, before traffic moves. A failed migration stops the deploy and the previous revision keeps serving.
* `required` stops a deploy that is missing a Shopify variable and names it, instead of starting an app that fails at its first request.
* The app reads its public URL from `FLOO_APP_URL`, which floo sets for each environment. You do not set `SHOPIFY_APP_URL` on floo.

## Point Shopify at floo

Shopify sends merchants and webhooks to the URLs in `shopify.app.toml`:

```toml shopify.app.toml theme={null}
application_url = "https://storefront-app.getfloo.app"

[auth]
redirect_urls = [ "https://storefront-app.getfloo.app/auth/callback" ]
```

`shopify app deploy` releases the configuration, including webhook subscriptions, to Shopify. Run it after every change to `shopify.app.toml`.

## Embedding in Shopify admin

floo's gateway sends `X-Frame-Options: SAMEORIGIN` on every response. The template also sends `Content-Security-Policy: frame-ancestors` for the merchant's shop and `https://admin.shopify.com`, through `addDocumentResponseHeaders` in `app/entry.server.tsx`. Browsers apply `frame-ancestors` in place of `X-Frame-Options`, so Shopify admin can frame the app and other sites cannot.

Remove that call and the app shows a blank frame in Shopify admin.

## Webhooks

Declare subscriptions in `shopify.app.toml` and handle each in a route under `app/routes/webhooks.*`. Every handler calls `authenticate.webhook(request)` first, which rejects a request without a valid Shopify signature.

Shopify retries a delivery that takes longer than five seconds to answer. Answer first, and move slow work to a [cron job](https://getfloo.com/docs/guides/cron-jobs.md).

A [cold start](https://getfloo.com/docs/guides/cold-starts.md) can use most of those five seconds: the floo starter app took 4.4 s after an hour idle. Keep prod ready with one warm instance, which bills while it idles:

```toml theme={null}
[environments.prod.resources]
min_instances = 1
```

An app listed on the Shopify App Store must also handle the three compliance webhooks (`customers/data_request`, `customers/redact`, `shop/redact`). They are commented out in the template's `shopify.app.toml`.

## Production

Create a second Shopify app for production stores, so development installs never touch merchants. Set its keys on floo's prod environment and release dev's version to prod:

```bash theme={null}
floo env set SHOPIFY_API_KEY --stdin --env prod
floo env set SHOPIFY_API_SECRET --stdin --env prod
floo env set SCOPES=write_products --env prod
floo promote
```

Point the production Shopify app's `application_url` and `redirect_urls` at the prod URL. `shopify app config link` creates a second config file, such as `shopify.app.production.toml`, and `shopify app deploy --config production` releases it. See [Environments](https://getfloo.com/docs/guides/environments.md) for how dev and prod differ.

## Local development

`shopify app dev` runs the app behind a Shopify tunnel and needs `DATABASE_URL`. `floo run` injects your dev database's credentials into a command:

```bash theme={null}
floo run --service web -- shopify app dev
```

If `shopify app dev` changes your app's URLs to its tunnel, run `shopify app deploy` afterwards to point them back at floo.

## Troubleshooting

| Symptom | Fix |
| - | - |
| Blank frame inside Shopify admin | The page is missing `frame-ancestors`. Keep `addDocumentResponseHeaders(request, responseHeaders)` in `app/entry.server.tsx`. |
| Deploy stops with `required env var(s) not set` | Set the named variables with `floo env set`, then `floo deploy --rebuild`. |
| Shopify reports a redirect URL error on install | `redirect_urls` in `shopify.app.toml` does not match the floo URL. Fix it and run `shopify app deploy`. |
| A webhook is rejected | The request has no valid HMAC. Check that `SHOPIFY_API_SECRET` on floo is the secret of the app sending the webhook. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.