Connecting directly to Postgres
Connecting to Postgres from Edge Functions.
Connect to your Postgres database from an Edge Function by using the
You can also use other Postgres clients like Deno Postgres
supabase-js client is a great option for connecting to your Supabase database since it handles authorization with Row Level Security, and it automatically formats your response as JSON.
Using a Postgres client#
Because Edge Functions are a server-side technology, it's safe to connect directly to your database using any popular Postgres client. This means you can run raw SQL from your Edge Functions.
Here is how you can connect to the database using Deno Postgres driver and run raw SQL.
Check out the full example.
Deployed edge functions are pre-configured to use SSL for connections to the Supabase database. You don't need to add any extra configurations.
If you want to use SSL connections during local development, follow these steps:
Download the SSL certificate from Database settings
In your local .env file, add these two variables:
_10SSL_CERT_FILE=/path/to/cert.crt # set the path to the downloaded cert_10DENO_TLS_CA_STORE=mozilla,system