diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts index 99b1cfd8caa86..719c333152d81 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts @@ -701,6 +701,50 @@ export const auth = { ], } +const ormQuickstarts: NavMenuSection = { + name: 'ORM Quickstarts', + url: undefined, + items: [ + { + name: 'Prisma', + url: '/guides/database/prisma', + items: [ + { + name: 'Prisma troubleshooting', + url: '/guides/database/prisma/prisma-troubleshooting', + }, + ], + }, + { + name: 'Drizzle', + url: '/guides/database/drizzle', + }, + { + name: 'Postgres.js', + url: '/guides/database/postgres-js', + }, + ], +} + +const guiQuickstarts: NavMenuSection = { + name: 'GUI quickstarts', + url: undefined, + items: [ + { + name: 'pgAdmin', + url: '/guides/database/pgadmin', + }, + { + name: 'PSQL', + url: '/guides/database/psql', + }, + { + name: 'DBeaver', + url: '/guides/database/dbeaver', + }, + ], +} + export const database: NavMenuConstant = { icon: 'database', title: 'Database', @@ -714,12 +758,6 @@ export const database: NavMenuConstant = { { name: 'Connecting to your database', url: '/guides/database/connecting-to-postgres', - items: [ - { - name: 'Serverless Drivers', - url: '/guides/database/connecting-to-postgres/serverless-drivers', - }, - ], }, { name: 'Importing data', url: '/guides/database/import-data' }, { name: 'Securing your data', url: '/guides/database/secure-data' }, @@ -864,48 +902,8 @@ export const database: NavMenuConstant = { }, ], }, - { - name: 'ORM Quickstarts', - url: undefined, - items: [ - { - name: 'Prisma', - url: '/guides/database/prisma', - items: [ - { - name: 'Prisma troubleshooting', - url: '/guides/database/prisma/prisma-troubleshooting', - }, - ], - }, - { - name: 'Drizzle', - url: '/guides/database/drizzle', - }, - { - name: 'Postgres.js', - url: '/guides/database/postgres-js', - }, - ], - }, - { - name: 'GUI quickstarts', - url: undefined, - items: [ - { - name: 'pgAdmin', - url: '/guides/database/pgadmin', - }, - { - name: 'PSQL', - url: '/guides/database/psql', - }, - { - name: 'DBeaver', - url: '/guides/database/dbeaver', - }, - ], - }, + ormQuickstarts, + guiQuickstarts, { name: 'Extensions', url: undefined, @@ -2540,4 +2538,6 @@ export const navDataForMdx = { nativeMobileLoginItems: NativeMobileLoginItems, phoneLoginsItems: PhoneLoginsItems, socialLoginItems: SocialLoginItems, + ormQuickstarts, + guiQuickstarts, } diff --git a/apps/docs/content/guides/database/connecting-to-postgres.mdx b/apps/docs/content/guides/database/connecting-to-postgres.mdx index dbf6406a713cd..a8e103f345110 100644 --- a/apps/docs/content/guides/database/connecting-to-postgres.mdx +++ b/apps/docs/content/guides/database/connecting-to-postgres.mdx @@ -1,89 +1,138 @@ --- -id: 'connecting-to-postgres' -title: 'Connecting to your database' -description: 'Explore the options for connecting to your Postgres database.' -subtitle: 'Explore the options for connecting to your Postgres database.' +title: 'Connect to your database' +description: 'Connect to Postgres from your frontend, backend, or serverless environment' +subtitle: 'Connect to Postgres from your frontend, backend, or serverless environment' --- -Supabase provides several options for programmatically connecting to your Postgres database: - -1. The Data APIs -1. Using one of the many [Client Libraries](/docs/reference) -1. Direct connections using the built-in Postgres connection system -1. Connection pooling for scalable connections - -## Data APIs - -Supabase's Data APIs are the easiest way to get started if you are managing data (fetching, inserting, updating). We provide several types of API to suit your preferences: - -- [REST](/docs/guides/api): interact with your database through a REST interface. -- [GraphQL](/docs/guides/graphql/api): interact with your database through a GraphQL interface. -- [Realtime](/docs/guides/realtime#realtime-api): listen to database changes over websockets. - -## Client libraries - -Supabase offers [client libraries](/docs/reference) for popular programming languages. These libraries provide a convenient wrapper around the Data APIs, making it easier to interact with your database using your preferred language. - -## Connecting to external libraries and tools - -Beyond the [Supabase client-libraries](/docs/guides/api/rest/client-libs), Supabase provides three connection strings for direct database access, compatible with all postgres libraries, such as [Prisma](/docs/guides/database/prisma) and [Drizzle](/docs/guides/database/drizzle), as well as tools like [PSQL](/docs/guides/database/psql) and [pgAdmin](/docs/guides/database/pgadmin). - -You can find these connection strings in your [Database Settings](https://supabase.com/dashboard/project/_/settings/database). - -### Direct connections: - -It connects directly to your Postgres instance. It is ideal for persistent servers, such as virtual machines (VMs) and long-lasting containers. Examples include AWS EC2 machines, Fly.io VMs, and DigitalOcean Droplets. +## Quick summary + +How you connect to your database depends on where you're connecting from: + +- For frontend applications, use the [Data API](#data-apis-and-client-libraries) +- For Postgres clients, use a connection string + - For persistent clients (for example, long-running servers or database GUIs) use the [direct connection string](#direct-connection) if your environment supports IPv6, and [Supavisor session mode](#supavisor-session-mode) if not + - For temporary clients (for example, serverless or edge functions) use [Supavisor transaction mode](#supavisor-transaction-mode) + +## Quickstarts + +
+ + {(data) => + data.items?.map((quickstart) => ( + + + + )) + } + + + {(data) => + data.items?.map((quickstart) => ( + + + + )) + } + +
+ +## Data APIs and client libraries + +The Data APIs allow you to interact with your database using REST or GraphQL requests. You can use these APIs to fetch and insert data from the frontend, as long as you have [RLS](/docs/guides/database/postgres/row-level-security) enabled. + +- [REST](/docs/guides/api) +- [GraphQL](/docs/guides/graphql/api) + +For convenience, you can also use the Supabase client libraries, which wrap the Data APIs with a developer-friendly interface and automatically handle authentication: + +- [JavaScript](/docs/reference/javascript) +- [Flutter](/docs/reference/dart) +- [Swift](/docs/reference/swift) +- [Python](/docs/reference/python) +- [C#](/docs/reference/csharp) +- [Kotlin](/docs/reference/kotlin) + +## Direct connection + +The direct connection string connects directly to your Postgres instance. It is ideal for persistent servers, such as virtual machines (VMs) and long-lasting containers. Examples include AWS EC2 machines, Fly.io VMs, and DigitalOcean Droplets. -Direct connections use IPv6 by default. If your environment doesn't support IPv6 or you're unsure but still want to use a direct connection, check out the [networking guide](/docs/guides/platform/ipv4-address#supabase-and-ipv6-compatibility) for more info. +Direct connections use IPv6 by default. If your environment doesn't support IPv6, use [Supavisor session mode](#supavisor-session-mode) or get the [IPv4 addon](/docs/guides/platform/ipv4-address). -```md -// Example String +The connection string looks like this: + +``` postgresql://postgres:[YOUR-PASSWORD]@db.apbkobhfnmcqqzqeeqss.supabase.co:5432/postgres ``` -You can find the direct connection string in the [Database settings](https://supabase.com/dashboard/project/_/settings/database) inside the dashboard: +Get your project's direct string from the [Database Settings](/dashboard/project/_/settings/database) page: 1. Go to the `Settings` section. 2. Click `Database`. -3. Under `Connection string`, make sure `Use connection pooling` is unchecked. Copy the URI. +3. Under `Connection string`, make sure `Display connection pooler` is unchecked. Copy the URI. -### Supavisor session mode (port 5432): +## Supavisor session mode -In Session mode, Supavisor acts as an IPv4 proxy. It allows developers in IPv4-only environments to access a direct-connection experience without needing the IPv4 add-on. +The session mode connection string connects to your Postgres instance via a proxy. This is ideal for persistent servers when IPv4 is not supported. -```md -// Example String +The connection string looks like this: + +``` postgres://postgres.apbkobhfnmcqqzqeeqss:[YOUR-PASSWORD]@aws-0-ca-central-1.pooler.supabase.com:5432/postgres ``` -### Transaction mode (port 6543): +Get your project's session mode string from the [Database Settings](/dashboard/project/_/settings/database) page: + +1. Go to the `Settings` section. +2. Click `Database`. +3. Under `Connection string`, make sure `Display connection pooler` is checked and `Session mode` is selected. Copy the URI. + +## Supavisor transaction mode + +The transaction mode connection string connects to your Postgres instance via a proxy which serves as a connection pooler. This is deal for serverless or edge functions, which require many transient connections. -Transaction mode does not support [prepared statements](https://postgresql.org/docs/current/sql-prepare.html). To avoid errors, [turn off prepared statements](https://github.com/orgs/supabase/discussions/28239) for your specific connection library. +Transaction mode does not support [prepared statements](https://postgresql.org/docs/current/sql-prepare.html). To avoid errors, [turn off prepared statements](https://github.com/orgs/supabase/discussions/28239) for your connection library. -Supavisor in transaction mode forms hot connections with the database and only allows clients to access them when a query is pending. It has amazing scaling capacity, and is best used with temporary servers, such as serverless/Edge Functions or auto-scaling servers. +The connection string looks like this: -```md -// Example String +``` postgres://postgres.apbkobhfnmcqqzqeeqss:[YOUR-PASSWORD]@aws-0-ca-central-1.pooler.supabase.com:6543/postgres ``` -## Connection pooling in-depth +Get your project's transaction mode string from the [Database Settings](/dashboard/project/_/settings/database) page: + +1. Go to the `Settings` section. +2. Click `Database`. +3. Under `Connection string`, make sure `Display connection pooler` is checked and `Transaction mode` is selected. Copy the URI. + +## More about connection pooling + +Connection pooling improves database performance by reusing existing connections between queries. This reduces the overhead of establishing connections and improves scalability. + +You can use an application-side pooler or a server-side pooler (Supabase automatically provides one called Supavisor), depending on whether your backend is persistent or serverless. -### Application side poolers +### Application-side poolers Application-side poolers are built into connection libraries and API servers, such as Prisma, SQLAlchemy, and PostgREST. They maintain several active connections with Postgres or a server-side pooler, reducing the overhead of establishing connections between queries. When deploying to static architecture, such as long-standing containers or VMs, application-side poolers are satisfactory on their own. ### Serverside poolers -Postgres connections are like WebSocket, once established, they are preserved until the client (application server) disconnects. A server might only make a single 10 ms query, but needlessly reserve its database connection for seconds or longer. +Postgres connections are like a WebSocket. Once established, they are preserved until the client (application server) disconnects. A server might only make a single 10 ms query, but needlessly reserve its database connection for seconds or longer. Serverside-poolers, such as Supabase's [Supavisor](https://github.com/supabase/supavisor) in transaction mode, sit between clients and the database and can be thought of as load balancers for Postgres connections. @@ -108,34 +157,6 @@ You can obtain your connection info and Server root certificate from your applic ![Connection Info and Certificate.](/docs/img/database/database-settings-ssl.png) -## Choosing a connection method - -- **Data APIs:** Best for operations supported by the Data APIs. -- **Supavisor Pooler:** - - **Transaction mode (port 6543):** Best for serverless/edge functions and rapidly auto-scaling servers - - **Session mode (port 5432):** For long-lived servers, such as virtual machines (VM) and enduring containers (if IPv6 is unsupported) -- **Direct Connections:** For long-lived servers, such as VMs and enduring containers (if IPv6 is supported or the IPv4 Add-On is enabled). - -## Quickstart connection guides - - - -If you'd like us to add a new quickstart guide, share your [feedback](https://supabase.com/dashboard/support/new), and we'll try to add it going forwards. - - - -### External libraries - -- [Prisma](/docs/guides/database/prisma) -- [Drizzle](/docs/guides/database/drizzle) -- [Postgres.js](/docs/guides/database/postgres-js) - -### External tools - -- [pgAdmin](/docs/guides/database/pgadmin) -- [PSQL](/docs/guides/database/psql) -- [DBeaver](/docs/guides/database/dbeaver) - ## Resources - [Connection management](/docs/guides/database/connection-management) diff --git a/apps/studio/components/interfaces/Billing/NoProjectsOnPaidOrgInfo.tsx b/apps/studio/components/interfaces/Billing/NoProjectsOnPaidOrgInfo.tsx index 870af2ef2d40b..e8f0c26b13456 100644 --- a/apps/studio/components/interfaces/Billing/NoProjectsOnPaidOrgInfo.tsx +++ b/apps/studio/components/interfaces/Billing/NoProjectsOnPaidOrgInfo.tsx @@ -2,7 +2,7 @@ import { useProjectsQuery } from 'data/projects/projects-query' import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query' import type { Organization } from 'types' import { Admonition } from 'ui-patterns' -import { Markdown } from '../Markdown' +import Link from 'next/link' interface NoProjectsOnPaidOrgInfoProps { organization?: Organization @@ -28,11 +28,11 @@ export const NoProjectsOnPaidOrgInfo = ({ organization }: NoProjectsOnPaidOrgInf type="default" title={`Your organization is on the ${orgSubscription.plan.name} plan with no projects running`} description={ - +
+ The monthly fees for the paid plan still apply. To cancel your subscription, head over to + your{' '} + organization billing settings +
} /> ) diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx index 8e8828f65ded7..57d3b730ba17f 100644 --- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx +++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/Subscription.tsx @@ -4,7 +4,6 @@ import dayjs from 'dayjs' import { ExternalLink } from 'lucide-react' import Link from 'next/link' -import { Markdown } from 'components/interfaces/Markdown' import { ScaffoldSection, ScaffoldSectionContent, @@ -147,10 +146,14 @@ const Subscription = () => { type="default" title="This organization is limited by the included usage" > - +
+ Projects may become unresponsive when this organization exceeds its + included usage quota. To scale + seamlessly and pay for over-usage, $ + {currentPlan?.id === 'free' + ? 'upgrade to a paid plan.' + : 'you can disable Spend Cap under the Cost Control settings.'} +