# File storage (/docs/starter/modules/storage)

Choose with `--storage s3` (default), `--storage supabase` (needs Supabase Auth), or `--storage none`. On [a React + Vite frontend with an API](../../cli/frontend-and-api.mdx#modules-on-these-stacks), the Hono and FastAPI APIs implement every option: see [A frontend and its API](#a-frontend-and-its-api).

<Tabs items={['S3-compatible', 'Supabase Storage']} groupId="storage" persist>
  <Tab value="S3-compatible">
    The storage adapter works with AWS S3 and S3-compatible providers such as Cloudflare R2 and MinIO. Configure `STORAGE_BUCKET`, `STORAGE_REGION`, `STORAGE_ENDPOINT` when required, and the access key, secret, and optional public URL. For R2, use the account's S3 API endpoint and region `auto`.

    Locally, Docker [local services](../local-services.mdx) run an S3-compatible server with the bucket `app`. Without Docker, uploads go to a local folder while `STORAGE_DIRECTORY` is set.
  </Tab>
  <Tab value="Supabase Storage">
    The storage adapter uses Supabase Storage through the signed-in user's Supabase session, so bucket policies can rely on that user. Set `SUPABASE_STORAGE_BUCKET` and choose a bucket policy that matches your application's access model.
  </Tab>
</Tabs>

<Callout type="warn">
  The storage adapter does not authorize users or validate uploads. Before calling it, the route must check ownership and authorization, file size, content type, and the object key. Keep credentials server side.
</Callout>

## A frontend and its API [#a-frontend-and-its-api]

With the Hono API (Starter v0.25.0 or newer) and the FastAPI API (Starter v0.26.0 or newer), the API holds the storage adapter. Set its variables in `apps/api/.env.local`, and in a route:

- **Hono:** call `getStorage(c.req.raw)` from `apps/api/src/server/storage.ts`.
- **FastAPI:** call `get_storage(request)` from `apps/api/src/clubedge_api/storage.py`, then await its `upload`, `download`, `delete`, `exists`, or `get_signed_url`.

With either API:

- **S3-compatible:** with `--infra local`, files go to the folder in `STORAGE_DIRECTORY`, relative to the API. `pnpm check:services` uploads, reads back, and deletes a test file.
- **Supabase Storage:** the adapter acts as the user whose Supabase access token the request carries (the `Authorization: Bearer` header the frontend sends), and as anonymous without one.
