Skip to content
Merged
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
16 changes: 8 additions & 8 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ To contribute code to [Supabase](https://supabase.com), you must fork the [Supab

### Install dependencies

1. Install the dependencies in the root of the repo.
1. Install the dependencies in the root of the repo:

```sh
pnpm install # install dependencies
Expand All @@ -77,7 +77,7 @@ To contribute code to [Supabase](https://supabase.com), you must fork the [Supab
cp apps/www/.env.local.example apps/www/.env.local
```

3. After that you can run the apps simultaneously with the following.
3. After that you can run the apps simultaneously with the following:
```sh
pnpm dev # start all the applications
```
Expand Down Expand Up @@ -117,8 +117,8 @@ Installing a package in a specific workspace requires you to move to the workspa

For example:

1. `cd apps/studio`: move to the `studio` workspace
2. `pnpm add react`: installs `react` into `studio` workspace
1. `cd apps/studio`: move to the `studio` workspace.
2. `pnpm add react`: installs `react` into `studio` workspace.


---
Expand All @@ -145,7 +145,7 @@ First, make sure you have the Docker installed on your device. You can download
cp .env.example .env
```

3. Run docker
3. Run docker:

```sh
docker compose up
Expand Down Expand Up @@ -186,9 +186,9 @@ Create a new entry in the [`redirects.js`](https://github.com/supabase/supabase/
We support "federating" docs, meaning doc content can come directly from external repos other than [`supabase/supabase`](https://github.com/supabase/supabase).

- It's great for things like client libs who have their own set of docs that we don't want to duplicate on the official Supabase docs (eg. [`supabase/vecs`](https://github.com/supabase/vecs)).
- No duplication or manual steps required - fetches and generates automatically as part of the docs build pipeline
- It's flexible - you can "embed" external docs nearly anywhere at any level in Supabase docs, but they will feel native
- If you are maintaining a repo containing docs that you think could also live in Supabase docs, feel free to create an issue and we can work together to integrate
- No duplication or manual steps required - fetches and generates automatically as part of the docs build pipeline.
- It's flexible - you can "embed" external docs nearly anywhere at any level in Supabase docs, but they will feel native.
- If you are maintaining a repo containing docs that you think could also live in Supabase docs, feel free to create an issue and we can work together to integrate.

Federated docs work using Next.js's build pipeline. We use `getStaticProps()` to fetch remote documentation (ie. markdown) at build time which is processed and passed to the respective page within the docs.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ export const functions: NavMenuConstant = {
url: undefined,
items: [
{ name: 'Background Tasks', url: '/guides/functions/background-tasks' },
{ name: 'Ephemeral Storage', url: '/guides/functions/ephemeral-storage' },
{ name: 'File Storage', url: '/guides/functions/ephemeral-storage' },
{ name: 'WebSockets', url: '/guides/functions/websockets' },
{ name: 'Custom Routing', url: '/guides/functions/routing' },
{ name: 'Wasm Modules', url: '/guides/functions/wasm' },
Expand Down
17 changes: 10 additions & 7 deletions apps/docs/content/_partials/project_setup.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## Project setup

Before we start building we're going to set up our Database and API. This is as simple as starting a new Project in Supabase and then creating a "schema" inside the database.
Before you start building you need to set up the Database and API. You can do this by starting a new Project in Supabase and then creating a "schema" inside the database.

### Create a project

1. [Create a new project](https://supabase.com/dashboard) in the Supabase Dashboard.
1. Enter your project details.
1. Wait for the new database to launch.
2. Enter your project details.
3. Wait for the new database to launch.

### Set up the database schema

Now we are going to set up the database schema. We can use the "User Management Starter" quickstart in the SQL Editor, or you can just copy/paste the SQL from below and run it yourself.
Now set up the database schema. You can use the "User Management Starter" quickstart in the SQL Editor, or you can copy/paste the SQL from below and run it.

<Tabs
scrollable
Expand All @@ -29,14 +29,16 @@ Now we are going to set up the database schema. We can use the "User Management

You can pull the database schema down to your local project by running the `db pull` command. Read the [local development docs](/docs/guides/cli/local-development#link-your-project) for detailed instructions.

</Admonition>
{/* TODO: discuss */}

```bash
supabase link --project-ref <project-id>
# You can get <project-id> from your project's dashboard URL: https://supabase.com/dashboard/project/<project-id>
supabase db pull
```

</Admonition>

</TabPanel>
<TabPanel id="sql" label="SQL">

Expand All @@ -58,7 +60,8 @@ supabase migration new user_management_starter
### Get the API keys

Now that you've created some database tables, you are ready to insert data using the auto-generated API.
We just need to get the Project URL and `anon` key from the API settings.

To do this, you need to get the Project URL and `anon` key from the API settings.

1. Go to the [API Settings](https://supabase.com/dashboard/project/_/settings/api) page in the Dashboard.
1. Find your Project `URL`, `anon`, and `service_role` keys on this page.
2. Find your Project `URL`, `anon`, and `service_role` keys on this page.
2 changes: 1 addition & 1 deletion apps/docs/content/guides/auth/server-side/nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To access Supabase from your Next.js app, you need 2 types of Supabase clients:
1. **Client Component client** - To access Supabase from Client Components, which run in the browser.
1. **Server Component client** - To access Supabase from Server Components, Server Actions, and Route Handlers, which run only on the server.

Create a `utils/supabase` folder with a file for each type of client. Then copy the utility functions for each client type.
Create a `utils/supabase` folder at the root of your project, or inside the `./src` folder if you are using one, with a file for each type of client. Then copy the utility functions for each client type.

<Accordion
type="default"
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/guides/cron.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Under the hood, Supabase Cron uses the [`pg_cron`](https://github.com/citusdata/

The extension creates a `cron` schema in your database and all Jobs are stored on the `cron.job` table. Every Job's run and its status is recorded on the `cron.job_run_details` table.

The Supabase Dashboard provides and interface for you to schedule Jobs and monitor Job runs. You can also do the same with SQL.
The Supabase Dashboard provides an interface for you to schedule Jobs and monitor Job runs. You can also do the same with SQL.

## Resources

Expand Down
84 changes: 63 additions & 21 deletions apps/docs/content/guides/functions/ephemeral-storage.mdx
Original file line number Diff line number Diff line change
@@ -1,21 +1,52 @@
---
id: 'function-ephemeral-storage'
title: 'Ephemeral Storage'
description: 'Read and write from temporary directory'
subtitle: 'Read and write from temporary directory'
title: 'File Storage'
description: 'Use persistent and ephemeral file storage'
subtitle: 'Use persistent and ephemeral file storage'
---

Edge Functions provides ephemeral file storage. You can read and write files to the `/tmp` directory.
Edge Functions provides two flavors of file storage:

This allows you to:
- Persistent - backed by S3 protocol, can read/write from any S3 compatible bucket, including Supabase Storage
- Ephemeral - You can read and write files to the `/tmp` directory. Only suitable for temporary operations

You can use file storage to:

- Process uploaded files temporarily without permanent storage
- Handle complex file transformations and workflows
- Do data migrations between projects
- Process user uploaded files and store them
- Unzip archives and process contents before saving to database

---

## Overview
## Persistent Storage

The persistent storage option is built on top of the S3 protocol. It allows you to mount any S3-compatible bucket, including Supabase Storage Buckets, as a directory for your Edge Functions.
You can perform operations such as reading and writing files to the mounted buckets as you would in a POSIX file system.

To access an S3 bucket from Edge Functions, you must set the following for environment variables in Edge Function Secrets.

- `S3FS_ENDPOINT_URL`
- `S3FS_REGION`
- `S3FS_ACCESS_KEY_ID`
- `S3FS_SECRET_ACCESS_KEY`

[Follow this guide](https://supabase.com/docs/guides/storage/s3/authentication) to enable and create an access key for Supabase Storage S3.

To access a file path in your mounted bucket from your Edge Function, use the prefix `/s3/YOUR-BUCKET-NAME`.

```tsx
// read from S3 bucket
const data = await Deno.readFile('/s3/my-bucket/results.csv')

// make a directory
await Deno.mkdir('/s3/my-bucket/sub-dir')

// write to S3 bucket
await Deno.writeTextFile('/s3/my-bucket/demo.txt', 'hello world')
```

## Ephemeral storage

Ephemeral storage will reset on each function invocation. This means the files you write during an invocation can only be read within the same invocation.

Expand Down Expand Up @@ -128,30 +159,41 @@ Deno.serve(async (req) => {

---

## Limitations
## Using synchronous file APIs

Currently, the synchronous APIs for creating or writing files are not supported:
You can safely use the following synchronous Deno APIs (and their Node counterparts) _during initial script evaluation_:

```tsx
// ❌ Not supported
Deno.writeFileSync('/tmp/file.txt', data)
Deno.mkdirSync('/tmp/directory')
- Deno.statSync
- Deno.removeSync
- Deno.writeFileSync
- Deno.writeTextFileSync
- Deno.readFileSync
- Deno.readTextFileSync
- Deno.mkdirSync
- Deno.makeTempDirSync
- Deno.readDirSync

// ✅ Supported
await Deno.writeFile('/tmp/file.txt', data)
await Deno.mkdir('/tmp/directory')
```

You can use sync variations of read APIs:
**Keep in mind** that the sync APIs are available only during initial script evaluation and aren’t supported in callbacks like HTTP handlers or `setTimeout`.

```tsx
// ✅ Supported
const data = Deno.readFileSync('/tmp/file.txt')
Deno.statSync('...') // ✅

setTimeout(() => {
Deno.statSync('...') // 💣 ERROR! Deno.statSync is blocklisted on the current context
})

Deno.serve(() => {
Deno.statSync('...') // 💣 ERROR! Deno.statSync is blocklisted on the current context
})
```

---

## Limits

There are no limits on S3 buckets you mount for Persistent storage.

Ephemeral Storage:

- Free projects: Up to 256MB of ephemeral storage
- Paid projects: Up to 512MB of ephemeral storage
Loading
Loading