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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
There is no fixed fee for a Preview branch. You only pay for the usage it incurs. With Compute costs of <Price price="0.01344" /> per hour, a branch running on Micro Compute size starts at <Price price="0.32" /> per day.
There is no fixed fee for a Preview branch. You only pay for the usage it incurs. A branch running on the default Micro Compute size starts at <Price price="0.01344" /> per hour.
2 changes: 1 addition & 1 deletion apps/docs/content/guides/deployment/branching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ You can make a similar setup with a distinct project for each environment. Or ju

Branching is available on the Pro Plan and above. The price is:

- Each Preview branch costs <Price price="0.32" /> per day
- Each Preview branch costs <Price price="0.01344" /> per hour
- Each Preview branch is billed until it is removed

## Troubleshooting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
useQueryTableCommands,
useSnippetCommands,
} from 'components/layouts/SQLEditorLayout/SqlEditor.Commands'
import { useGenerateSqlCommand } from 'components/interfaces/SqlGenerator/SqlGenerator.Commands'
import { useProjectLevelTableEditorCommands } from 'components/layouts/TableEditorLayout/TableEditor.Commands'
import { useLayoutNavCommands } from 'components/layouts/useLayoutNavCommands'
import { CommandHeader, CommandInput, CommandList, CommandMenu } from 'ui-patterns/CommandMenu'
Expand All @@ -19,7 +18,6 @@ import { useSupportCommands } from './Support'
import { orderCommandSectionsByPriority } from './ordering'

export default function StudioCommandMenu() {
useGenerateSqlCommand()
useApiKeysCommands()
useApiUrlCommand()
useProjectLevelTableEditorCommands()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { IS_PLATFORM } from 'lib/constants'
import { useAppStateSnapshot } from 'state/app-state'
import { removeTabsByEditor } from 'state/tabs'
import { Badge, Button, Modal, ScrollArea, cn } from 'ui'
import { APISidePanelPreview } from './APISidePanelPreview'
import { CLSPreview } from './CLSPreview'
Expand Down Expand Up @@ -58,13 +57,6 @@ const FeaturePreviewModal = () => {
properties: { feature: selectedFeatureKey },
groups: { project: ref ?? 'Unknown', organization: org?.slug ?? 'Unknown' },
})

if (ref && selectedFeatureKey === LOCAL_STORAGE_KEYS.UI_TABLE_EDITOR_TABS) {
removeTabsByEditor(ref, 'table')
}
if (ref && selectedFeatureKey === LOCAL_STORAGE_KEYS.UI_SQL_EDITOR_TABS) {
removeTabsByEditor(ref, 'sql')
}
}

function handleCloseFeaturePreviewModal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export const CreateBranchModal = ({ visible, onClose }: CreateBranchModalProps)
<DialogFooter className="sm:justify-between gap-2" padding="medium">
<p className="flex items-center gap-2 text-sm text-foreground">
<DollarSign size={16} strokeWidth={1.5} />
Each preview branch costs $0.32 per day
Each preview branch costs $0.01344 per hour
</p>
<div className="flex items-center gap-2">
<Button disabled={isCreating} type="default" onClick={onClose}>
Expand Down
23 changes: 16 additions & 7 deletions apps/studio/components/interfaces/Connect/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { ExternalLink, Plug } from 'lucide-react'
import { parseAsBoolean, useQueryState } from 'nuqs'
import { useState } from 'react'
import { useState, useMemo } from 'react'

import { DatabaseConnectionString } from 'components/interfaces/Connect/DatabaseConnectionString'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import Panel from 'components/ui/Panel'
import { getAPIKeys, useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
import { useAPIKeysQuery } from 'data/api-keys/api-keys-query'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
import { PROJECT_STATUS } from 'lib/constants'
Expand Down Expand Up @@ -137,13 +138,21 @@ export const Connect = () => {
return []
}

const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint ?? ''
const apiHost = canReadAPIKeys ? `${protocol}://${endpoint ?? '-'}` : ''
const apiUrl = canReadAPIKeys ? apiHost : null

const { anonKey } = canReadAPIKeys ? getAPIKeys(settings) : { anonKey: null }
const projectKeys = { apiUrl, anonKey: anonKey?.api_key ?? null }
const { data: apiKeys } = useAPIKeysQuery({ projectRef, reveal: false })

const projectKeys = useMemo(() => {
const protocol = settings?.app_config?.protocol ?? 'https'
const endpoint = settings?.app_config?.endpoint ?? ''
const apiHost = canReadAPIKeys ? `${protocol}://${endpoint ?? '-'}` : ''

const apiUrl = canReadAPIKeys ? apiHost : null
return {
apiUrl: apiHost ?? null,
anonKey: anonKey?.api_key ?? null,
publishableKey: apiKeys?.find(({ type }) => type === 'publishable')?.api_key ?? null,
}
}, [apiKeys, anonKey, canReadAPIKeys, settings])

const filePath = getContentFilePath({
connectionObject,
Expand Down
4 changes: 3 additions & 1 deletion apps/studio/components/interfaces/Connect/Connect.types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export type projectKeys = {
apiUrl: string | null
anonKey: string | null
publishableKey: string | null
}

export interface ContentFileProps {
projectKeys: {
apiUrl: string
anonKey: string
anonKey?: string
publishableKey?: string
}
connectionStringPooler: {
transactionShared: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data class TodoItem(val id: Int, val name: String)
{`
val supabase = createSupabaseClient(
supabaseUrl = "${projectKeys.apiUrl ?? 'your-project-url'}",
supabaseKey = "${projectKeys.anonKey ?? 'your-anon-key'}"
supabaseKey = "${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile apps>'}"
) {
install(Postgrest)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
SUPABASE_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
`}
</SimpleCodeBlock>
</ConnectTabContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
EXPO_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
EXPO_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
EXPO_PUBLIC_SUPABASE_KEY=${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}
`}
</SimpleCodeBlock>
</ConnectTabContent>
Expand All @@ -31,17 +31,18 @@ EXPO_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
{`
import 'react-native-url-polyfill/auto'
import AsyncStorage from '@react-native-async-storage/async-storage'
import { createClient } from '@supabase/supabase-js'
import { createClient, processLock } from '@supabase/supabase-js'

export const supabase = createClient(
process.env.EXPO_PUBLIC_SUPABASE_URL || "",
process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY || "",
process.env.EXPO_PUBLIC_SUPABASE_URL!,
process.env.EXPO_PUBLIC_SUPABASE_KEY!,
{
auth: {
storage: AsyncStorage,
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
lock: processLock,
},
})
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'package:supabase_flutter/supabase_flutter.dart';
Future<void> main() async {
await Supabase.initialize(
url: '${projectKeys.apiUrl ?? 'your-project-url'}',
anonKey: '${projectKeys.anonKey ?? 'your-anon-key'}',
anonKey: '${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile and desktop apps>'}',
);
runApp(MyApp());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {
{`
export const environment = {
supabaseUrl: '${projectKeys.apiUrl ?? 'your-project-url'}',
supabaseKey: '${projectKeys.anonKey ?? 'your-anon-key'}',
supabaseKey: '${projectKeys.publishableKey ?? '<prefer publishabke key instead of anon key for mobile apps>'}',
};
`}
</SimpleCodeBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
REACT_APP_SUPABASE_KEY=${projectKeys.publishableKey ?? '<prefer publishable key instead of anon key for mobile or desktop apps>'}
`}
</SimpleCodeBlock>
</ConnectTabContent>
Expand All @@ -32,7 +32,7 @@ REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
import { createClient } from '@supabase/supabase-js'

const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEY
const supabaseKey = process.env.REACT_APP_SUPABASE_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey)
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {

<ConnectTabContent value=".env.local">
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
`}
{[
'',
`NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
projectKeys?.publishableKey
? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
: `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
'',
].join('\n')}
</SimpleCodeBlock>
</ConnectTabContent>

Expand Down Expand Up @@ -58,10 +62,13 @@ export default async function Page() {
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { cookies } from "next/headers";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};

export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
supabaseUrl!,
supabaseKey!,
{
cookies: {
getAll() {
Expand All @@ -88,10 +95,13 @@ export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
{`
import { createBrowserClient } from "@supabase/ssr";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};

export const createClient = () =>
createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
supabaseUrl!,
supabaseKey!,
);
`}
</SimpleCodeBlock>
Expand All @@ -103,6 +113,9 @@ export const createClient = () =>
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { type NextRequest, NextResponse } from "next/server";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};

export const createClient = (request: NextRequest) => {
// Create an unmodified response
let supabaseResponse = NextResponse.next({
Expand All @@ -112,8 +125,8 @@ export const createClient = (request: NextRequest) => {
});

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
supabaseUrl!,
supabaseKey!,
{
cookies: {
getAll() {
Expand All @@ -134,7 +147,6 @@ export const createClient = (request: NextRequest) => {

return supabaseResponse
};

`}
</SimpleCodeBlock>
</ConnectTabContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {

<ConnectTabContent value=".env.local">
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
`}
{[
'',
`NEXT_PUBLIC_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
projectKeys?.publishableKey
? `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
: `NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
'',
].join('\n')}
</SimpleCodeBlock>
</ConnectTabContent>

Expand All @@ -32,7 +36,7 @@ NEXT_PUBLIC_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
import { createClient } from "@supabase/supabase-js";

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
const supabaseKey = process.env.${projectKeys?.publishableKey ? 'NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'NEXT_PUBLIC_SUPABASE_ANON_KEY'};

export const supabase = createClient(supabaseUrl, supabaseKey);
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
SUPABASE_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
SUPABASE_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}
`}
</SimpleCodeBlock>
</ConnectTabContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {

<ConnectTabContent value=".env.local">
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
`}
{[
'',
`REACT_APP_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
projectKeys?.publishableKey
? `REACT_APP_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
: `REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
'',
].join('\n')}
</SimpleCodeBlock>
</ConnectTabContent>

Expand All @@ -32,7 +36,7 @@ REACT_APP_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
import { createClient } from "@supabase/supabase-js";

const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
const supabaseKey = process.env.REACT_APP_SUPABASE_ANON_KEY;
const supabaseKey = process.env.${projectKeys.publishableKey ? 'REACT_APP_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'REACT_APP_SUPABASE_ANON_KEY'};

export const supabase = createClient(supabaseUrl, supabaseKey);
`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ const ContentFile = ({ projectKeys }: ContentFileProps) => {

<ConnectTabContent value=".env">
<SimpleCodeBlock className="bash" parentClassName="min-h-72">
{`
VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}
VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
`}
{[
'',
`VITE_SUPABASE_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
projectKeys?.publishableKey
? `VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY=${projectKeys.publishableKey}`
: `VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
'',
].join('\n')}
</SimpleCodeBlock>
</ConnectTabContent>

Expand All @@ -32,7 +36,8 @@ VITE_SUPABASE_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
const supabaseKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY' : 'VITE_SUPABASE_ANON_KEY'};

const supabase = createClient(supabaseUrl, supabaseKey);

export default supabase
Expand Down
Loading
Loading