The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactor: migrate guides to app router (#23101)
Charisf4779d4844ee
diff --git a/apps/docs/app/error.tsx b/apps/docs/app/error.tsxnew file mode 100644index 00000000000..ab0dd867544--- /dev/null+++ b/apps/docs/app/error.tsx@@ -0,0 +1,17 @@+'use client'++import Link from 'next/link'+import { Button } from 'ui'++const ErrorPage = () => (+ <div className="h-full w-full flex flex-col gap-8 p-8 items-center justify-center">+ <span className="text-center text-5xl text-foreground-lighter">+ Sorry, something went wrong+ </span>+ <Button asChild type="secondary" className="w-fit p-4 text-lg">+ <Link href="/">Return to homepage</Link>+ </Button>+ </div>+)++export default ErrorPagediff --git a/apps/docs/app/guides/[...slug]/page.tsx b/apps/docs/app/guides/[...slug]/page.tsxnew file mode 100644index 00000000000..2bbfc101eea--- /dev/null+++ b/apps/docs/app/guides/[...slug]/page.tsx@@ -0,0 +1,19 @@+import {+ getGuidesMarkdown,+ genGuideMeta,+ genGuidesStaticParams,+} from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate } from '~/features/docs/GuidesMdx.template'++type Params = { slug: string[] }++const GuidePage = async ({ params }: { params: Params }) => {+ const data = await getGuidesMarkdown(params)+ return <GuideTemplate {...data!} />+}++const generateStaticParams = genGuidesStaticParams()+const generateMetadata = genGuideMeta(getGuidesMarkdown)++export default GuidePage+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/app/guides/ai/python/[slug]/page.tsx b/apps/docs/app/guides/ai/python/[slug]/page.tsxnew file mode 100644index 00000000000..29c2c903e9f--- /dev/null+++ b/apps/docs/app/guides/ai/python/[slug]/page.tsx@@ -0,0 +1,133 @@+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { redirect } from 'next/navigation'+import { relative } from 'path'+import rehypeSlug from 'rehype-slug'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { notFoundLink } from '~/features/recommendations/NotFound.utils'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'++// We fetch these docs at build time from an external repo+const org = 'supabase'+const repo = 'vecs'+const branch = 'main'+const docsDir = 'docs'+const externalSite = 'https://supabase.github.io/vecs'++// Each external docs page is mapped to a local page+const pageMap = [+ {+ slug: 'api',+ meta: {+ title: 'API',+ },+ remoteFile: 'api.md',+ },+ {+ slug: 'collections',+ meta: {+ title: 'Collections',+ },+ remoteFile: 'concepts_collections.md',+ },+ {+ slug: 'indexes',+ meta: {+ title: 'Indexes',+ },+ remoteFile: 'concepts_indexes.md',+ },+ {+ slug: 'metadata',+ meta: {+ title: 'Metadata',+ },+ remoteFile: 'concepts_metadata.md',+ },+]++interface Params {+ slug: string+}++const PythonClientDocs = async ({ params }: { params: Params }) => {+ const { meta, ...data } = await getContent(params)++ const options = {+ mdxOptions: {+ remarkPlugins: [remarkMkDocsAdmonition, [removeTitle, meta.title]],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ } as SerializeOptions++ return <GuideTemplate mdxOptions={options} meta={meta} {...data} />+}++/**+ * Fetch markdown from external repo+ */+const getContent = async ({ slug }: Params) => {+ const page = pageMap.find(({ slug: validSlug }) => validSlug && validSlug === slug)++ if (!page) {+ redirect(notFoundLink(`api/python/${slug}`))+ }++ const { remoteFile, meta } = page++ const editLink = newEditLink(`${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}`)++ const response = await fetch(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`+ )++ const content = await response.text()++ return {+ pathname: `/guides/ai/python/${slug}` satisfies `/${string}`,+ meta,+ content,+ editLink,+ }+}++const urlTransform: UrlTransformFunction = (url) => {+ try {+ const externalSiteUrl = new URL(externalSite)++ const placeholderHostname = 'placeholder'+ const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)++ // Don't modify a url with a FQDN or a url that's only a hash+ if (hostname !== placeholderHostname || pathname === '/') {+ return url+ }++ const relativePage = (+ pathname.endsWith('.md')+ ? pathname.replace(/\.md$/, '')+ : relative(externalSiteUrl.pathname, pathname)+ ).replace(/^\//, '')++ const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)++ // If we have a mapping for this page, use the mapped path+ if (page) {+ return page.slug + hash+ }++ // If we don't have this page in our docs, link to original docs+ return `${externalSite}/${relativePage}${hash}`+ } catch (err) {+ console.error('Error transforming markdown URL', err)+ return url+ }+}++const generateStaticParams = () => pageMap.map(({ slug }) => ({ slug }))+const generateMetadata = genGuideMeta(getContent)++export default PythonClientDocs+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/pages/guides/cli/config.tsx b/apps/docs/app/guides/cli/config/page.tsxsimilarity index 56%rename from apps/docs/pages/guides/cli/config.tsxrename to apps/docs/app/guides/cli/config/page.tsxindex 89b16e55973..4707208e7e0 100644--- a/apps/docs/pages/guides/cli/config.tsx+++ b/apps/docs/app/guides/cli/config/page.tsx@@ -1,60 +1,45 @@-import Head from 'next/head'import ReactMarkdown from 'react-markdown'--import { CodeBlock, cn } from 'ui'-+import { CodeBlock } from 'ui'import { Heading } from 'ui/src/components/CustomHTMLElements'-import GuidesTableOfContents from '~/components/GuidesTableOfContents'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import { MainSkeleton } from '~/layouts/MainSkeleton'-import { Parameter } from '~/lib/refGenerator/refTypes'+import { type TOCHeader } from '~/components/GuidesTableOfContents'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import type { Parameter } from '~/lib/refGenerator/refTypes'import specFile from '~/spec/cli_v1_config.yaml' assert { type: 'yml' }-// Parameters are grouped on the page by tag-const tocList = []-const content = specFile.info.tags.map((tag) => {- tocList.push({ text: tag.title, link: `${tag.id}-config`, level: 2 })+const meta = {+ title: 'Supabase CLI config',+}++const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/cli/config',+ meta,+}))++const tocList: TOCHeader[] = []+const content = specFile.info.tags.map((tag: { id: string; title: string }, id: number) => {+ tocList.push({ id: `${id}`, text: tag.title, link: `${tag.id}-config`, level: 2 })return (<div><Heading tag="h2">{tag.title} Config</Heading>{specFile.parameters- .filter((param: Parameter) => param.tags[0] === tag.id)- .map((parameter: Parameter) => {- tocList.push({ text: parameter.id, link: `#${parameter.id}`, level: 3 })+ .filter((param: Parameter) => param.tags && param.tags[0] === tag.id)+ .map((parameter: Parameter, id: number) => {+ tocList.push({ id: `${id}`, text: parameter.id, link: `#${parameter.id}`, level: 3 })return <Info parameter={parameter} />})}</div>)})-export default function Config() {+const Config = () => {+ const editLink = newEditLink('supabase/supabase/blob/master/apps/docs/spec/cli_v1_config.yaml')+return (- <>- <Head>- <title>Supabase CLI config</title>- </Head>- <MainSkeleton menuId={MenuId.Cli}>- <div className="grid grid-cols-12 relative gap-4 px-5 max-w-7xl mx-auto py-16">- <div className="relative col-span-12 md:col-span-9 transition-all ease-out duration-100">- <div className="w-full prose">- <h1>CLI configuration</h1>- <div className="max-w-xs w-32 h-[1px] bg-gradient-to-r from-brand-300 to-brand my-8"></div>- <ReactMarkdown>{specFile.info.description}</ReactMarkdown>- <div>{content}</div>- </div>- </div>- <GuidesTableOfContents- overrideToc={tocList}- className={cn(- 'col-span-3 self-start',- 'hidden md:block md:col-span-3',- 'sticky top-[calc(var(--header-height,40px)+2rem)]',- 'max-h-[calc(100vh-60px-5rem)]'- )}- />- </div>- </MainSkeleton>- </>+ <GuideTemplate meta={meta} editLink={editLink}>+ <ReactMarkdown>{specFile.info.description}</ReactMarkdown>+ <div>{content}</div>+ </GuideTemplate>)}@@ -81,7 +66,7 @@ function Info({ parameter }: { parameter: Parameter }) {<tr><td>{parameter.id}</td><td>{parameter.default ? parameter.default.toString() : 'None'}</td>- <td>{parameter.required.toString()}</td>+ <td>{parameter.required !== undefined && parameter.required.toString()}</td></tr></tbody></table>@@ -116,3 +101,6 @@ function Info({ parameter }: { parameter: Parameter }) {</div>)}++export default Config+export { generateMetadata }diff --git a/apps/docs/app/guides/cli/github-action/[slug]/page.tsx b/apps/docs/app/guides/cli/github-action/[slug]/page.tsxnew file mode 100644index 00000000000..f42057ac118--- /dev/null+++ b/apps/docs/app/guides/cli/github-action/[slug]/page.tsx@@ -0,0 +1,132 @@+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { redirect } from 'next/navigation'+import { relative } from 'node:path'+import rehypeSlug from 'rehype-slug'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { notFoundLink } from '~/features/recommendations/NotFound.utils'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'+import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'++// We fetch these docs at build time from an external repo+const org = 'supabase'+const repo = 'setup-cli'+const branch = 'gh-pages'+const docsDir = 'docs'+const externalSite = 'https://supabase.github.io/setup-cli'++// Each external docs page is mapped to a local page+const pageMap = [+ {+ slug: 'generating-types',+ meta: {+ title: 'Generate types using GitHub Actions',+ description: 'End-to-end type safety across client, server, and database.',+ subtitle: 'End-to-end type safety across client, server, and database.',+ tocVideo: 'VSNgAIObBdw',+ },+ remoteFile: 'generating-types.md',+ },+ {+ slug: 'testing',+ meta: {+ title: 'Automated testing using GitHub Actions',+ description: 'Run your tests when you or your team make changes.',+ subtitle: 'Run your tests when you or your team make changes.',+ },+ remoteFile: 'testing.md',+ },+ {+ slug: 'backups',+ meta: {+ title: 'Automated backups using GitHub Actions',+ description: 'Backup your database on a regular basis.',+ subtitle: 'Backup your database on a regular basis.',+ },+ remoteFile: 'backups.md',+ },+]++type Params = { slug: string }++const ActionDocs = async ({ params }: { params: Params }) => {+ const { meta, ...data } = await getContent(params)++ const options = {+ mdxOptions: {+ remarkPlugins: [remarkMkDocsAdmonition, remarkPyMdownTabs, [removeTitle, meta.title]],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ } as SerializeOptions++ return <GuideTemplate mdxOptions={options} meta={meta} {...data} />+}++/**+ * Fetch markdown from external repo+ */+const getContent = async ({ slug }: Params) => {+ const page = pageMap.find(({ slug: validSlug }) => validSlug && validSlug === slug)++ if (!page) {+ redirect(notFoundLink(`cli/github-action/${slug}`))+ }++ const { remoteFile, meta } = page++ const editLink = newEditLink(`${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}`)++ const response = await fetch(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`+ )++ const content = await response.text()++ return {+ pathname: `/guides/cli/github-action/${slug}` satisfies `/${string}`,+ meta,+ content,+ editLink,+ }+}++const urlTransform: UrlTransformFunction = (url) => {+ try {+ const externalSiteUrl = new URL(externalSite)++ const placeholderHostname = 'placeholder'+ const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)++ // Don't modify a url with a FQDN or a url that's only a hash+ if (hostname !== placeholderHostname || pathname === '/') {+ return url+ }++ const relativePage = (+ pathname.endsWith('.md')+ ? pathname.replace(/\.md$/, '')+ : relative(externalSiteUrl.pathname, pathname)+ ).replace(/^\//, '')++ const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)++ // If we have a mapping for this page, use the mapped path+ if (page) {+ return page.slug + hash+ }++ // If we don't have this page in our docs, link to original docs+ return `${externalSite}/${relativePage}${hash}`+ } catch (err) {+ console.error('Error transforming markdown URL', err)+ return url+ }+}++const generateStaticParams = () => pageMap.map(({ slug }) => ({ slug }))+const generateMetadata = genGuideMeta(getContent)++export default ActionDocs+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/pages/guides/database/database-advisors.tsx b/apps/docs/app/guides/database/database-advisors/page.tsxsimilarity index 52%rename from apps/docs/pages/guides/database/database-advisors.tsxrename to apps/docs/app/guides/database/database-advisors/page.tsxindex a699383dce3..2f9293e9295 100644--- a/apps/docs/pages/guides/database/database-advisors.tsx+++ b/apps/docs/app/guides/database/database-advisors/page.tsx@@ -1,36 +1,34 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'import { Octokit } from '@octokit/core'import { capitalize } from 'lodash'-import { GetStaticProps, InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import remarkGfm from 'remark-gfm'+import { type SerializeOptions } from 'next-mdx-remote/dist/types'import rehypeSlug from 'rehype-slug'--import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }--import components from '~/components'import { Heading } from 'ui'-import { TabPanel, Tabs } from '~/components/Tabs'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'+import { Tabs, TabPanel } from '~/features/ui/Tabs'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'// We fetch these docs at build time from an external repo-export const org = 'supabase'-export const repo = 'splinter'-export const branch = 'main'-export const docsDir = 'docs'+const org = 'supabase'+const repo = 'splinter'+const branch = 'main'+const docsDir = 'docs'const meta = {title: 'Performance and Security Advisors',subtitle: 'Check your database for performance and security issues',}-const editLink = 'https://github.com/supabase/splinter/tree/main/docs'+const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/database/database-linter',+ meta,+}))++const editLink = newEditLink('supabase/splinter/tree/main/docs')const markdownIntro = `You can use the Database Performance and Security Advisors to check your database for issues such as missing indexes and improperly set-up RLS policies.@@ -40,15 +38,21 @@ You can use the Database Performance and Security Advisors to check your databasIn the dashboard, navigate to [Security Advisor](https://supabase.com/dashboard/project/_/database/security-advisor) and [Performance Advisor](https://supabase.com/dashboard/project/_/database/performance-advisor) under Database. The advisors run automatically. You can also manually rerun them after you've resolved issues.`.trim()-const getBasename = (path: string) => path.split('/').at(-1).replace(/\.md$/, '')+const getBasename = (path: string) => path.split('/').at(-1)!.replace(/\.md$/, '')++const DatabaseAdvisorDocs = async () => {+ const { lints, lintsList } = await getLints()++ const options = {+ mdxOptions: {+ remarkPlugins: [remarkMkDocsAdmonition, remarkPyMdownTabs, [removeTitle, meta.title]],+ rehypePlugins: [[linkTransform, urlTransform(lintsList)], rehypeSlug],+ },+ } as SerializeOptions-export default function DatabaseAdvisorDocs({- intro,- lints,-}: InferGetStaticPropsType<typeof getStaticProps>) {return (- <Layout menuId={MenuId.Database} meta={meta} editLink={editLink}>- <MDXRemote {...intro} components={components} />+ <GuideTemplate meta={meta} editLink={editLink}>+ <MDXRemoteGuides source={markdownIntro} /><Heading tag="h2">Available checks</Heading><Tabs listClassNames="flex flex-wrap gap-2 [&>button]:!m-0" queryGroup="lint">{lints.map((lint) => (@@ -58,12 +62,12 @@ export default function DatabaseAdvisorDocs({label={capitalize(getBasename(lint.path).replace(/_/g, ' '))}><section id={getBasename(lint.path)}>- <MDXRemote {...lint.content} components={components} />+ <MDXRemoteGuides source={lint.content} options={options} /></section></TabPanel>))}</Tabs>- </Layout>+ </GuideTemplate>)}@@ -101,41 +105,10 @@ const urlTransform: (lints: Array<{ path: string }>) => UrlTransformFunction = (}}-const transformMarkdown = async (- rawContent: string,- { replacementLinks = [] }: { replacementLinks?: Array<{ path: string }> } = {}-) => {- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const content = await serialize(rawContent, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- remarkPyMdownTabs,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform(replacementLinks)], rehypeSlug],- },- })-- return content-}-/**- * Fetch markdown from external repo and transform links+ * Fetch lint remediation Markdown from external repo*/-export const getStaticProps = (async () => {+const getLints = async () => {const octokit = new Octokit()const response = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {@@ -154,37 +127,33 @@ export const getStaticProps = (async () => {if (!Array.isArray(response.data)) {throw Error(- `Reading a directory, not a file. Should not reach this, solely to appease Typescript.`+ 'Reading a directory, not a file. Should not reach this, solely to appease Typescript.')}- const [intro, ...lints] = await Promise.all([- await transformMarkdown(markdownIntro),- ...response.data- .filter(({ path }) => /docs\/\d+.+\.md$/.test(path))- .map(async ({ path }, _, data) => {- const fileResponse = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${path}`- )-- if (fileResponse.status >= 400) {- throw Error(`Could not get contents of file ${org}/${repo}/${path}`)- }-- const rawContent = await fileResponse.text()- const content = await transformMarkdown(rawContent, { replacementLinks: data })-- return {- path: getBasename(path),- content,- }- }),- ])-- return {- props: {- intro,- lints,- },- }-}) satisfies GetStaticProps+ const lintsList = response.data.filter(({ path }) => /docs\/\d+.+\.md$/.test(path))++ const lints = await Promise.all(+ lintsList.map(async ({ path }) => {+ const fileResponse = await fetch(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${path}`+ )++ if (fileResponse.status >= 400) {+ throw Error(`Could not get contents of file ${org}/${repo}/${path}`)+ }++ const content = await fileResponse.text()++ return {+ path: getBasename(path),+ content,+ }+ })+ )++ return { lints, lintsList }+}++export default DatabaseAdvisorDocs+export { generateMetadata }diff --git a/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsxnew file mode 100644index 00000000000..f8be35c3f64--- /dev/null+++ b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx@@ -0,0 +1,220 @@+import matter from 'gray-matter'+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { readFile } from 'node:fs/promises'+import { join, relative } from 'node:path'+import rehypeSlug from 'rehype-slug'+import emoji from 'remark-emoji'+import { genGuideMeta, genGuidesStaticParams } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { GUIDES_DIRECTORY, isValidGuideFrontmatter } from '~/lib/docs'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'+import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'++// We fetch these docs at build time from an external repo+const org = 'supabase'+const repo = 'wrappers'+const branch = 'main'+const docsDir = 'docs'+const externalSite = 'https://supabase.github.io/wrappers'++// Each external docs page is mapped to a local page+const pageMap = [+ {+ slug: 'airtable',+ meta: {+ title: 'Airtable',+ },+ remoteFile: 'airtable.md',+ },+ {+ slug: 'auth0',+ meta: {+ title: 'Auth0',+ },+ remoteFile: 'auth0.md',+ },+ {+ slug: 'bigquery',+ meta: {+ title: 'BigQuery',+ },+ remoteFile: 'bigquery.md',+ },+ {+ slug: 'clickhouse',+ meta: {+ title: 'ClickHouse',+ },+ remoteFile: 'clickhouse.md',+ },+ {+ slug: 'cognito',+ meta: {+ title: 'AWS Cognito',+ },+ remoteFile: 'cognito.md',+ },+ {+ slug: 'firebase',+ meta: {+ title: 'Firebase',+ },+ remoteFile: 'firebase.md',+ },+ {+ slug: 'logflare',+ meta: {+ title: 'Logflare',+ },+ remoteFile: 'logflare.md',+ },+ {+ slug: 'mssql',+ meta: {+ title: 'MSSQL',+ },+ remoteFile: 'mssql.md',+ },+ {+ slug: 'redis',+ meta: {+ title: 'Redis',+ },+ remoteFile: 'redis.md',+ },+ {+ slug: 's3',+ meta: {+ title: 'AWS S3',+ },+ remoteFile: 's3.md',+ },+ {+ slug: 'stripe',+ meta: {+ title: 'Stripe',+ },+ remoteFile: 'stripe.md',+ },+]++interface Params {+ slug?: string[]+}++const WrappersDocs = async ({ params }: { params: Params }) => {+ const { isExternal, meta, ...data } = await getContent(params)++ const options = isExternal+ ? ({+ mdxOptions: {+ remarkPlugins: [+ remarkMkDocsAdmonition,+ emoji,+ remarkPyMdownTabs,+ [removeTitle, meta.title],+ ],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ } as SerializeOptions)+ : undefined++ return <GuideTemplate meta={meta} mdxOptions={options} {...data} />+}++/**+ * Fetch markdown from external repo+ */+const getContent = async (params: Params) => {+ const federatedPage = pageMap.find(+ ({ slug }) => params && slug && params.slug && slug === params.slug.at(0)+ )++ let isExternal: boolean+ let meta: any+ let content: string+ let editLink: string++ if (!federatedPage) {+ isExternal = false+ editLink = `supabase/supabase/apps/docs/content/guides/database/extensions/wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}.mdx`+ const rawContent = await readFile(+ join(+ GUIDES_DIRECTORY,+ 'database',+ 'extensions',+ `wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}.mdx`+ ),+ 'utf-8'+ )+ ;({ data: meta, content } = matter(rawContent))+ if (!isValidGuideFrontmatter(meta)) {+ throw Error(`Expected valid frontmatter, got ${JSON.stringify(meta, null, 2)}`)+ }+ } else {+ isExternal = true+ let remoteFile: string+ ;({ remoteFile, meta } = federatedPage)+ const repoPath = `${org}/${repo}/${branch}/${docsDir}/${remoteFile}`+ editLink = `${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}`+ const response = await fetch(`https://raw.githubusercontent.com/${repoPath}`)+ content = await response.text()+ }++ return {+ pathname:+ `/guides/database/extensions/wrappers${params.slug?.length ? `/${params.slug.join('/')}` : ''}` satisfies `/${string}`,+ isExternal,+ editLink: newEditLink(editLink),+ meta,+ content,+ }+}++const urlTransform: UrlTransformFunction = (url) => {+ try {+ const externalSiteUrl = new URL(externalSite)++ const placeholderHostname = 'placeholder'+ const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)++ // Don't modify a url with a FQDN or a url that's only a hash+ if (hostname !== placeholderHostname || pathname === '/') {+ return url+ }+ const relativePage = (+ pathname.endsWith('.md')+ ? pathname.replace(/\.md$/, '')+ : relative(externalSiteUrl.pathname, pathname)+ ).replace(/^\//, '')++ const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)++ // If we have a mapping for this page, use the mapped path+ if (page) {+ return page.slug + hash+ }++ // If we don't have this page in our docs, link to original docs+ return `${externalSite}/${relativePage}${hash}`+ } catch (err) {+ console.error('Error transforming markdown URL', err)+ return url+ }+}++const generateStaticParams = async () => {+ const mdxPaths = await genGuidesStaticParams('database/extensions/wrappers')()+ const federatedPaths = pageMap.map(({ slug }) => ({+ slug: [slug],+ }))++ return [...mdxPaths, ...federatedPaths]+}++const generateMetadata = genGuideMeta(getContent)++export default WrappersDocs+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/app/guides/graphql/[[...slug]]/page.tsx b/apps/docs/app/guides/graphql/[[...slug]]/page.tsxnew file mode 100644index 00000000000..eec27cf55f2--- /dev/null+++ b/apps/docs/app/guides/graphql/[[...slug]]/page.tsx@@ -0,0 +1,192 @@+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { redirect } from 'next/navigation'+import { isAbsolute, relative } from 'path'+import rehypeSlug from 'rehype-slug'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { notFoundLink } from '~/features/recommendations/NotFound.utils'+import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'+import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'+import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'+import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'++// We fetch these docs at build time from an external repo+const org = 'supabase'+const repo = 'pg_graphql'+const branch = 'master'+const docsDir = 'docs'+const externalSite = 'https://supabase.github.io/pg_graphql'++// Each external docs page is mapped to a local page+const pageMap = [+ {+ meta: {+ id: 'graphql-overview',+ title: 'GraphQL',+ subtitle: 'Autogenerated GraphQL APIs with Postgres.',+ },+ remoteFile: 'supabase.md',+ },+ {+ slug: 'api',+ meta: {+ id: 'graphql-api',+ title: 'GraphQL API',+ subtitle: 'Understanding the core concepts of the GraphQL API.',+ },+ remoteFile: 'api.md',+ },+ {+ slug: 'views',+ meta: {+ id: 'graphql-views',+ title: 'Views',+ subtitle: 'Using Postgres Views with GraphQL.',+ },+ remoteFile: 'views.md',+ },+ {+ slug: 'functions',+ meta: {+ id: 'graphql-functions',+ title: 'Functions',+ subtitle: 'Using Postgres Functions with GraphQL.',+ },+ remoteFile: 'functions.md',+ },+ {+ slug: 'computed-fields',+ meta: {+ id: 'graphql-computed-fields',+ title: 'Computed Fields',+ subtitle: 'Using Postgres Computed Fields with GraphQL.',+ },+ remoteFile: 'computed-fields.md',+ },+ {+ slug: 'configuration',+ meta: {+ id: 'graphql-configuration',+ title: 'Configuration & Customization',+ subtitle: 'Extra configuration options can be set on SQL entities using comment directives.',+ },+ remoteFile: 'configuration.md',+ },+ {+ slug: 'security',+ meta: {+ id: 'graphql-security',+ title: 'Security',+ subtitle: 'Securing your GraphQL API.',+ },+ remoteFile: 'security.md',+ },+ {+ slug: 'with-apollo',+ meta: {+ id: 'graphql-with-apollo',+ title: 'With Apollo',+ subtitle: 'Using pg_grapqhl with Apollo.',+ },+ remoteFile: 'usage_with_apollo.md',+ },+ {+ slug: 'with-relay',+ meta: {+ id: 'graphql-with-relay',+ title: 'With Relay',+ subtitle: 'Using pg_grapqhl with Relay.',+ },+ remoteFile: 'usage_with_relay.md',+ },+]++interface Params {+ slug?: string[]+}++const PGGraphQLDocs = async ({ params }: { params: Params }) => {+ const { meta, ...data } = await getContent(params)++ const options = {+ mdxOptions: {+ remarkPlugins: [remarkMkDocsAdmonition, remarkPyMdownTabs, [removeTitle, meta.title]],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ } as SerializeOptions++ return <GuideTemplate mdxOptions={options} meta={meta} {...data} />+}++/**+ * Fetch markdown from external repo and transform links+ */+const getContent = async ({ slug }: Params) => {+ const page = pageMap.find((page) => page.slug === slug?.at(0))++ if (!page) {+ redirect(notFoundLink(`graphql/${slug ? slug.join('/') : ''}`))+ }++ const { remoteFile, meta } = page++ const editLink = newEditLink(`${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}`)++ const response = await fetch(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`+ )++ const content = await response.text()++ return {+ pathname: `/guides/graphql${slug?.length ? `/${slug.join('/')}` : ''}` satisfies `/${string}`,+ meta,+ content,+ editLink,+ }+}++const urlTransform: UrlTransformFunction = (url) => {+ try {+ const externalSiteUrl = new URL(externalSite)++ const placeholderHostname = 'placeholder'+ const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)++ // Don't modify a url with a FQDN or a url that's only a hash+ if (hostname !== placeholderHostname || pathname === '/') {+ return url+ }++ const getRelativePath = () => {+ if (pathname.endsWith('.md')) {+ return pathname.replace(/\.md$/, '')+ }+ if (isAbsolute(url)) {+ return relative(externalSiteUrl.pathname, pathname)+ }+ return pathname+ }++ const relativePath = getRelativePath().replace(/^\//, '')++ const page = pageMap.find(({ remoteFile }) => `${relativePath}.md` === remoteFile)++ // If we have a mapping for this page, use the mapped path+ if (page) {+ return 'graphql/' + page.slug + hash+ }++ // If we don't have this page in our docs, link to original docs+ return `${externalSite}/${relativePath}${hash}`+ } catch (err) {+ console.error('Error transforming markdown URL', err)+ return url+ }+}++const generateStaticParams = async () => pageMap.map(({ slug }) => ({ slug: slug ? [slug] : [] }))+const generateMetadata = genGuideMeta(getContent)++export default PGGraphQLDocs+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/app/guides/layout.tsx b/apps/docs/app/guides/layout.tsxnew file mode 100644index 00000000000..20be5f75f9f--- /dev/null+++ b/apps/docs/app/guides/layout.tsx@@ -0,0 +1,50 @@+'use client'++import { usePathname } from 'next/navigation'+import { type PropsWithChildren } from 'react'+import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'+import Layout from '~/layouts/guides'++const GuidesLayout = ({ children }: PropsWithChildren) => {+ const pathname = usePathname()+ const menuId = getMenuId(pathname)++ return <Layout menuId={menuId}>{children}</Layout>+}++const getMenuId = (pathname: string | null) => {+ pathname = (pathname ??= '').replace(/^\/guides\//, '')++ switch (true) {+ case pathname.startsWith('ai'):+ return MenuId.Ai+ case pathname.startsWith('api'):+ return MenuId.Api+ case pathname.startsWith('auth'):+ return MenuId.Auth+ case pathname.startsWith('cli'):+ return MenuId.Cli+ case pathname.startsWith('database'):+ return MenuId.Database+ case pathname.startsWith('functions'):+ return MenuId.Functions+ case pathname.startsWith('getting-started'):+ return MenuId.GettingStarted+ case pathname.startsWith('graphql'):+ return MenuId.Graphql+ case pathname.startsWith('platform'):+ return MenuId.Platform+ case pathname.startsWith('realtime'):+ return MenuId.Realtime+ case pathname.startsWith('resources'):+ return MenuId.Resources+ case pathname.startsWith('self-hosting'):+ return MenuId.SelfHosting+ case pathname.startsWith('storage'):+ return MenuId.Storage+ default:+ return MenuId.Home+ }+}++export default GuidesLayoutdiff --git a/apps/docs/pages/guides/platform/terraform/[[...slug]].tsx b/apps/docs/app/guides/platform/terraform/[[...slug]]/page.tsxsimilarity index 50%rename from apps/docs/pages/guides/platform/terraform/[[...slug]].tsxrename to apps/docs/app/guides/platform/terraform/[[...slug]]/page.tsxindex 1eb6d14123f..79421d21f8b 100644--- a/apps/docs/pages/guides/platform/terraform/[[...slug]].tsx+++ b/apps/docs/app/guides/platform/terraform/[[...slug]]/page.tsx@@ -1,27 +1,21 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'import matter from 'gray-matter'-import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import remarkGfm from 'remark-gfm'+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { redirect } from 'next/navigation'import rehypeSlug from 'rehype-slug'--import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { notFoundLink } from '~/features/recommendations/NotFound.utils'import { isValidGuideFrontmatter } from '~/lib/docs'import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'--// We fetch these docs at build time from an external repo-export const org = 'supabase'-export const repo = 'terraform-provider-supabase'-export const branch = 'v1.1.3'-export const docsDir = 'docs'+import {+ terraformDocsBranch,+ terraformDocsDocsDir,+ terraformDocsOrg,+ terraformDocsRepo,+} from '../terraformConstants'// Each external docs page is mapped to a local pageconst pageMap = [@@ -41,16 +35,21 @@ const pageMap = [},]-export default function TerraformDocs({- source,- meta,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- return (- <Layout menuId={MenuId.Platform} meta={meta} editLink={editLink}>- <MDXRemote {...source} components={components} />- </Layout>- )+interface Params {+ slug?: string[]+}++const TerraformDocs = async ({ params }: { params: Params }) => {+ const { meta, ...data } = await getContent(params)++ const options = {+ mdxOptions: {+ remarkPlugins: [remarkMkDocsAdmonition, remarkPyMdownTabs, [removeTitle, meta.title]],+ rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],+ },+ } as SerializeOptions++ return <GuideTemplate mdxOptions={options} meta={meta} {...data} />}/**@@ -88,7 +87,7 @@ const urlTransform: UrlTransformFunction = (url: string) => {}// If we don't have this page in our docs, link to GitHub repo- return `https://github.com/${org}/${repo}/blob/${branch}${pathname}${hash}`+ return `https://github.com/${terraformDocsOrg}/${terraformDocsRepo}/blob/${terraformDocsBranch}${pathname}${hash}`} catch (err) {console.error('Error transforming markdown URL', err)return url@@ -96,72 +95,47 @@ const urlTransform: UrlTransformFunction = (url: string) => {}/**- * Fetch markdown from external repo and transform links+ * Fetch markdown from external repo*/-export const getStaticProps = (async ({ params }) => {- const [slug] = params.slug ?? []- const page = pageMap.find((page) => page.slug === slug)+const getContent = async ({ slug }: Params) => {+ const [requestedSlug] = slug ?? []+ const page = pageMap.find((page) => page.slug === requestedSlug)if (!page) {- throw new Error(`No page mapping found for slug '${slug}'`)+ redirect(notFoundLink('platform/terraform' + (slug?.join('/') ?? '')))}const { meta, remoteFile, useRoot } = page+ const editLink = newEditLink(+ `${terraformDocsOrg}/${terraformDocsRepo}/blob/${terraformDocsBranch}/${useRoot ? '' : `${terraformDocsDocsDir}/`}${remoteFile}`+ )+let response = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${useRoot ? '' : `${docsDir}/`}${remoteFile}`+ `https://raw.githubusercontent.com/${terraformDocsOrg}/${terraformDocsRepo}/${terraformDocsBranch}/${useRoot ? '' : `${terraformDocsDocsDir}/`}${remoteFile}`)- let content = await response.text()+ let rawContent = await response.text()// Strip out HTML comments- content = content.replace(/<!--.*?-->/, '')- const { content: source, data } = matter(content)+ rawContent = rawContent.replace(/<!--.*?-->/, '')+ const { content, data } = matter(rawContent)Object.assign(meta, data)if (!isValidGuideFrontmatter(meta)) {throw Error('Guide frontmatter is invalid.')}- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const mdxSource = await serialize(source, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- remarkPyMdownTabs,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],- },- })-return {- props: {- source: mdxSource,- meta,- editLink: `${org}/${repo}/blob/${branch}/${docsDir}/${slug}.md`,- },+ pathname:+ `/guides/platform/terraform${slug?.length ? `/${slug.join('/')}` : ''}` satisfies `/${string}`,+ meta,+ content,+ editLink,}-}) satisfies GetStaticProps+}-export const getStaticPaths = (async () => {- return {- paths: pageMap.map(({ slug }) => ({- params: {- slug: slug ? [slug] : [],- },- })),- fallback: false,- }-}) satisfies GetStaticPaths+const generateStaticParams = async () => pageMap.map(({ slug }) => ({ slug: slug ? [slug] : [] }))+const generateMetadata = genGuideMeta(getContent)++export default TerraformDocs+export { generateStaticParams, generateMetadata }diff --git a/apps/docs/pages/guides/platform/terraform/reference.tsx b/apps/docs/app/guides/platform/terraform/reference/page.tsxsimilarity index 88%rename from apps/docs/pages/guides/platform/terraform/reference.tsxrename to apps/docs/app/guides/platform/terraform/reference/page.tsxindex 8004ab606c9..0268a3a21d7 100644--- a/apps/docs/pages/guides/platform/terraform/reference.tsx+++ b/apps/docs/app/guides/platform/terraform/reference/page.tsx@@ -1,22 +1,33 @@import { codeBlock } from 'common-tags'-import { GetStaticProps, InferGetStaticPropsType } from 'next'+import { Check, PlusCircle } from 'lucide-react'import Link from 'next/link'import ReactMarkdown from 'react-markdown'-import {CodeBlock,Heading,- IconCheck,- IconPlusCircle,PopoverContent_Shadcn_,PopoverTrigger_Shadcn_,Popover_Shadcn_,- Tabs,} from 'ui'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, newEditLink } from '~/features/docs/GuidesMdx.template'+import { TabPanel, Tabs } from '~/features/ui/Tabs'+import {+ terraformDocsBranch,+ terraformDocsDocsDir,+ terraformDocsOrg,+ terraformDocsRepo,+} from '../terraformConstants'++const meta = {+ title: 'Terraform Provider reference',+ subtitle: 'Resources and data sources available through the Terraform Provider',+}-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { org, repo, branch, docsDir } from './[[...slug]]'+const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/platform/terraform/reference',+ meta,+}))function ProviderSettings({ schema }: { schema: any }) {const attributes = schema.block.attributes@@ -63,7 +74,7 @@ function ProviderSettings({ schema }: { schema: any }) {<td className="align-middle">{attributes[attribute].optional && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -71,7 +82,7 @@ function ProviderSettings({ schema }: { schema: any }) {<td className="align-middle">{attributes[attribute].sensitive && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -92,7 +103,7 @@ function Resources({ schema }: { schema: any }) {<p>You can configure these resources using the Supabase Terraform provider:</p><Tabs>{Object.keys(schema).map((resource) => (- <Tabs.Panel id={resource} label={resource}>+ <TabPanel id={resource} label={resource}><Heading tag="h4">Example usage</Heading><CodeBlock className="not-prose">{codeBlock`resource "${resource}" "<label>" {@@ -137,7 +148,7 @@ function Resources({ schema }: { schema: any }) {<PopoverTrigger_Shadcn_ asChild><button className="flex items-center justify-between gap-2">Nested type- <IconPlusCircle size={14} className="shrink-0" />+ <PlusCircle size={14} className="shrink-0" /></button></PopoverTrigger_Shadcn_><PopoverContent_Shadcn_ className="max-h-[50vh] overflow-auto">@@ -177,7 +188,7 @@ function Resources({ schema }: { schema: any }) {<td className="align-middle">{schema[resource].block.attributes[attribute].required && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -185,7 +196,7 @@ function Resources({ schema }: { schema: any }) {<td className="align-middle">{schema[resource].block.attributes[attribute].optional && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -193,7 +204,7 @@ function Resources({ schema }: { schema: any }) {<td className="align-middle">{schema[resource].block.attributes[attribute].computed && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -202,7 +213,7 @@ function Resources({ schema }: { schema: any }) {))}</tbody></table>- </Tabs.Panel>+ </TabPanel>))}</Tabs></section>@@ -216,7 +227,7 @@ function DataSources({ schema }: { schema: any }) {<p>You can read these resources using the Supabase Terraform provider:</p><Tabs>{Object.keys(schema).map((dataSource) => (- <Tabs.Panel id={dataSource} label={dataSource}>+ <TabPanel id={dataSource} label={dataSource}><Heading tag="h4">Example usage</Heading><CodeBlock className="not-prose">{codeBlock`resource "${dataSource}" "all" {@@ -263,7 +274,7 @@ function DataSources({ schema }: { schema: any }) {<PopoverTrigger_Shadcn_ asChild><button className="flex items-center justify-between gap-2">Nested type- <IconPlusCircle size={14} />+ <PlusCircle size={14} /></button></PopoverTrigger_Shadcn_><PopoverContent_Shadcn_ className="max-h-[50vh] overflow-auto">@@ -306,7 +317,7 @@ function DataSources({ schema }: { schema: any }) {<td className="align-middle">{schema[dataSource].block.attributes[attribute].required && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -314,7 +325,7 @@ function DataSources({ schema }: { schema: any }) {<td className="align-middle">{schema[dataSource].block.attributes[attribute].optional && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -322,7 +333,7 @@ function DataSources({ schema }: { schema: any }) {<td className="align-middle">{schema[dataSource].block.attributes[attribute].computed && (<>- <IconCheck className="ml-[2.5ch]" />+ <Check className="ml-[2.5ch]" /><span className="sr-only">true</span></>)}@@ -331,19 +342,20 @@ function DataSources({ schema }: { schema: any }) {))}</tbody></table>- </Tabs.Panel>+ </TabPanel>))}</Tabs></section>)}-export default function PGGraphQLDocs({- meta,- schema,-}: InferGetStaticPropsType<typeof getStaticProps>) {+const TerraformReferencePage = async () => {+ const { schema } = await getSchema()++ const editLink = newEditLink('supabase/terraform-provider-supabase')+return (- <Layout menuId={MenuId.Platform} meta={meta}>+ <GuideTemplate meta={meta} editLink={editLink}>The Terraform Provider provices access to{' '}<Linkhref="https://developer.hashicorp.com/terraform/language/resources"@@ -371,30 +383,25 @@ export default function PGGraphQLDocs({schema.provider_schemas['registry.terraform.io/supabase/supabase'].data_source_schemas}/>- </Layout>+ </GuideTemplate>)}/*** Fetch JSON schema from external repo*/-export const getStaticProps = (async () => {- const meta = {- title: 'Terraform Provider reference',- subtitle: 'Resources and data sources available through the Terraform Provider',- }-+const getSchema = async () => {let response = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/schema.json`+ `https://raw.githubusercontent.com/${terraformDocsOrg}/${terraformDocsRepo}/${terraformDocsBranch}/${terraformDocsDocsDir}/schema.json`)if (!response.ok) throw Error('Failed to fetch Terraform JSON schema from GitHub')const schema = await response.json()return {- props: {- meta,- schema,- },+ schema,}-}) satisfies GetStaticProps+}++export default TerraformReferencePage+export { generateMetadata }diff --git a/apps/docs/app/guides/platform/terraform/terraformConstants.ts b/apps/docs/app/guides/platform/terraform/terraformConstants.tsnew file mode 100644index 00000000000..0cc7ad3125b--- /dev/null+++ b/apps/docs/app/guides/platform/terraform/terraformConstants.ts@@ -0,0 +1,9 @@+/**+ * Information on where to fetch docs content+ */+const terraformDocsOrg = 'supabase'+const terraformDocsRepo = 'terraform-provider-supabase'+const terraformDocsBranch = 'v1.1.3'+const terraformDocsDocsDir = 'docs'++export { terraformDocsOrg, terraformDocsRepo, terraformDocsBranch, terraformDocsDocsDir }diff --git a/apps/docs/app/guides/self-hosting/analytics/config/page.tsx b/apps/docs/app/guides/self-hosting/analytics/config/page.tsxnew file mode 100644index 00000000000..fa67144d69a--- /dev/null+++ b/apps/docs/app/guides/self-hosting/analytics/config/page.tsx@@ -0,0 +1,63 @@+import Param from '~/components/Params'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'+import { getAnalyticsConfigV0 } from '~/lib/mdx/getConfig'++const meta = {+ title: 'Analytics Self-hosting Config',+ description: 'How to configure and deploy Supabase Analytics.',+}++const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/self-hosting/analytics/config',+ meta,+}))++const AnalyticsConfigPage = async () => {+ const spec = getAnalyticsConfigV0()+ const descriptionMdx = spec.info.description++ return (+ <GuideTemplate+ meta={meta}+ editLink={newEditLink(+ 'supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/analytics/config.tsx'+ )}+ >+ <MDXRemoteGuides source={descriptionMdx} />++ <div>+ {spec.info.tags.map((tag: ReturnType<typeof getAnalyticsConfigV0>['info']['tags']) => {+ return (+ <>+ <h2 className="text-foreground">{tag.title}</h2>+ <p className="text-foreground-lighter">{tag.description}</p>+ <div className="not-prose">+ <h5 className="text-base text-foreground mb-3">Parameters</h5>+ <ul>+ {spec.parameters+ .filter((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) =>+ param.tags.includes(tag.id)+ )+ .map((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) => {+ return (+ <Param+ name={param.title}+ type={param.type}+ description={param.description}+ required={param.required}+ />+ )+ })}+ </ul>+ </div>+ </>+ )+ })}+ </div>+ </GuideTemplate>+ )+}++export default AnalyticsConfigPage+export { generateMetadata }diff --git a/apps/docs/app/guides/self-hosting/auth/config/page.tsx b/apps/docs/app/guides/self-hosting/auth/config/page.tsxnew file mode 100644index 00000000000..3285ed9af36--- /dev/null+++ b/apps/docs/app/guides/self-hosting/auth/config/page.tsx@@ -0,0 +1,63 @@+import Param from '~/components/Params'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'+import { getAuthConfigV1 } from '~/lib/mdx/getConfig'++const meta = {+ title: 'Auth Self-hosting Config',+ description: 'How to configure and deploy Supabase Auth.',+}++const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/self-hosting/auth/config',+ meta,+}))++const AuthConfigPage = async () => {+ const spec = getAuthConfigV1()+ const descriptionMdx = spec.info.description++ return (+ <GuideTemplate+ meta={meta}+ editLink={newEditLink(+ 'supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/auth/config.tsx'+ )}+ >+ <MDXRemoteGuides source={descriptionMdx} />++ <div>+ {spec.info.tags.map((tag: ReturnType<typeof getAuthConfigV1>['info']['tags']) => {+ return (+ <>+ <h2 className="text-foreground">{tag.title}</h2>+ <p className="text-foreground-lighter">{tag.description}</p>+ <div className="not-prose">+ <h5 className="text-base text-foreground mb-3">Parameters</h5>+ <ul>+ {spec.parameters+ .filter((param: ReturnType<typeof getAuthConfigV1>['parameters']) =>+ param.tags.includes(tag.id)+ )+ .map((param: ReturnType<typeof getAuthConfigV1>['parameters']) => {+ return (+ <Param+ name={param.title}+ type={param.type}+ description={param.description}+ required={param.required}+ />+ )+ })}+ </ul>+ </div>+ </>+ )+ })}+ </div>+ </GuideTemplate>+ )+}++export default AuthConfigPage+export { generateMetadata }diff --git a/apps/docs/app/guides/self-hosting/realtime/config/page.tsx b/apps/docs/app/guides/self-hosting/realtime/config/page.tsxnew file mode 100644index 00000000000..5e5abbc20b6--- /dev/null+++ b/apps/docs/app/guides/self-hosting/realtime/config/page.tsx@@ -0,0 +1,63 @@+import Param from '~/components/Params'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'+import { getRealtimeConfigV0 } from '~/lib/mdx/getConfig'++const meta = {+ title: 'Realtime Self-hosting Config',+ description: 'How to configure and deploy Supabase Realtime.',+}++const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/self-hosting/realtime/config',+ meta,+}))++const RealtimeConfigPage = async () => {+ const spec = getRealtimeConfigV0()+ const descriptionMdx = spec.info.description++ return (+ <GuideTemplate+ meta={meta}+ editLink={newEditLink(+ 'supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/realtime/config.tsx'+ )}+ >+ <MDXRemoteGuides source={descriptionMdx} />++ <div>+ {spec.info.tags.map((tag: ReturnType<typeof getRealtimeConfigV0>['info']['tags']) => {+ return (+ <>+ <h2 className="text-foreground">{tag.title}</h2>+ <p className="text-foreground-lighter">{tag.description}</p>+ <div className="not-prose">+ <h5 className="text-base text-foreground mb-3">Parameters</h5>+ <ul>+ {spec.parameters+ .filter((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) =>+ param.tags.includes(tag.id)+ )+ .map((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) => {+ return (+ <Param+ name={param.title}+ type={param.type}+ description={param.description}+ required={param.required}+ />+ )+ })}+ </ul>+ </div>+ </>+ )+ })}+ </div>+ </GuideTemplate>+ )+}++export default RealtimeConfigPage+export { generateMetadata }diff --git a/apps/docs/app/guides/self-hosting/storage/config/page.tsx b/apps/docs/app/guides/self-hosting/storage/config/page.tsxnew file mode 100644index 00000000000..874c3e02fda--- /dev/null+++ b/apps/docs/app/guides/self-hosting/storage/config/page.tsx@@ -0,0 +1,63 @@+import Param from '~/components/Params'+import { genGuideMeta } from '~/features/docs/GuidesMdx.utils'+import { GuideTemplate, MDXRemoteGuides, newEditLink } from '~/features/docs/GuidesMdx.template'+import { getStorageConfigV0 } from '~/lib/mdx/getConfig'++const meta = {+ title: 'Storage Self-hosting Config',+ description: 'How to configure and deploy Supabase Storage.',+}++const generateMetadata = genGuideMeta(() => ({+ pathname: '/guides/self-hosting/storage/config',+ meta,+}))++const StorageConfigPage = async () => {+ const spec = getStorageConfigV0()+ const descriptionMdx = spec.info.description++ return (+ <GuideTemplate+ meta={meta}+ editLink={newEditLink(+ 'supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/storage/config.tsx'+ )}+ >+ <MDXRemoteGuides source={descriptionMdx} />++ <div>+ {spec.info.tags.map((tag: ReturnType<typeof getStorageConfigV0>['info']['tags']) => {+ return (+ <>+ <h2 className="text-foreground">{tag.title}</h2>+ <p className="text-foreground-lighter">{tag.description}</p>+ <div className="not-prose">+ <h5 className="text-base text-foreground mb-3">Parameters</h5>+ <ul>+ {spec.parameters+ .filter((param: ReturnType<typeof getStorageConfigV0>['parameters']) =>+ param.tags.includes(tag.id)+ )+ .map((param: ReturnType<typeof getStorageConfigV0>['parameters']) => {+ return (+ <Param+ name={param.title}+ type={param.type}+ description={param.description}+ required={param.required}+ />+ )+ })}+ </ul>+ </div>+ </>+ )+ })}+ </div>+ </GuideTemplate>+ )+}++export default StorageConfigPage+export { generateMetadata }diff --git a/apps/docs/app/not-found/layout.tsx b/apps/docs/app/not-found/layout.tsxnew file mode 100644index 00000000000..fe86169838e--- /dev/null+++ b/apps/docs/app/not-found/layout.tsx@@ -0,0 +1,21 @@+import { type Metadata } from 'next'+import { type PropsWithChildren } from 'react'+import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'+import { LayoutMainContent } from '~/layouts/DefaultLayout'+import { MainSkeleton } from '~/layouts/MainSkeleton'++const metadata: Metadata = {+ title: 'Not found',+ robots: {+ index: false,+ },+}++const NotFoundLayout = ({ children }: PropsWithChildren) => (+ <MainSkeleton menuId={MenuId.Home}>+ <LayoutMainContent>{children}</LayoutMainContent>+ </MainSkeleton>+)++export default NotFoundLayout+export { metadata }diff --git a/apps/docs/app/not-found/page.tsx b/apps/docs/app/not-found/page.tsxnew file mode 100644index 00000000000..1863e98671d--- /dev/null+++ b/apps/docs/app/not-found/page.tsx@@ -0,0 +1,38 @@+import { createClient } from '@supabase/supabase-js'+import { type Metadata } from 'next'++import { DocsSearchResult, type Database } from 'common'++import { NotFound } from '~/features/recommendations/NotFound.client'++const metadata: Metadata = {+ robots: {+ index: false,+ follow: false,+ },+}++const NotFoundPage = async ({ searchParams: { page } }: { searchParams: { page?: string } }) => {+ const recommendations = page ? await getRecommendations(page) : null++ return <NotFound recommendations={recommendations} />+}++const getRecommendations = async (page: string) => {+ const query = decodeURIComponent(page.replace(/^\/(?:guides|reference)\//, '')).replace(+ /[_\/-]/g,+ ' '+ )+ if (!query) return null++ const supabase = createClient<Database>(+ process.env.NEXT_PUBLIC_SUPABASE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!+ )+ const { data, error } = await supabase.rpc('docs_search_fts', { query })+ if (error || !data?.length) return null+ return data as Omit<DocsSearchResult, 'sections'>[]+}++export default NotFoundPage+export { metadata }diff --git a/apps/docs/components/ApiSchema.tsx b/apps/docs/components/ApiSchema.tsxindex 98ee6ab01e2..42a5b195566 100644--- a/apps/docs/components/ApiSchema.tsx+++ b/apps/docs/components/ApiSchema.tsx@@ -1,6 +1,6 @@import { CodeBlock } from '@ui/components/CodeBlock'import { sample } from '@har-sdk/openapi-sampler'-import { Tabs, TabPanel } from '~/components/Tabs'+import { Tabs, TabPanel } from '~/features/ui/Tabs'type IParamProps = anydiff --git a/apps/docs/components/AppleSecretGenerator/index.tsx b/apps/docs/components/AppleSecretGenerator/index.tsxindex ea66eadd23a..ea556ac7de9 100644--- a/apps/docs/components/AppleSecretGenerator/index.tsx+++ b/apps/docs/components/AppleSecretGenerator/index.tsx@@ -1,11 +1,9 @@-import { lazy, Suspense } from 'react'+'use client'-const Generator = lazy(() => import('./AppleSecretGenerator'))+import dynamic from 'next/dynamic'++const Generator = dynamic(() => import('./AppleSecretGenerator'), { ssr: false })export function AppleSecretGenerator() {- return (- <Suspense>- <Generator />- </Suspense>- )+ return <Generator />}diff --git a/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.tsx b/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.tsxindex e0e74bcd7ac..2039a78854e 100644--- a/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.tsx+++ b/apps/docs/components/AuthSmsProviderConfig/AuthSmsProviderConfig.tsx@@ -1,3 +1,5 @@+'use client'+import { useEffect, useReducer, useRef } from 'react'import { PhoneLoginsItems } from '../Navigation/NavigationMenu/NavigationMenu.constants'import { IconPanel } from 'ui-patterns/IconPanel'diff --git a/apps/docs/components/ButtonCard.tsx b/apps/docs/components/ButtonCard.tsxindex 5180cc90786..ecc50fd15c0 100644--- a/apps/docs/components/ButtonCard.tsx+++ b/apps/docs/components/ButtonCard.tsx@@ -1,6 +1,7 @@import React, { FC } from 'react'import Image from 'next/legacy/image'import Link from 'next/link'+import { cn } from 'ui'interface Props {title: string@@ -9,6 +10,7 @@ interface Props {icon?: string | anychildren?: anylayout?: 'vertical' | 'horizontal'+ className?: string}const ButtonCard: FC<Props> = ({@@ -18,14 +20,16 @@ const ButtonCard: FC<Props> = ({description = '',to,layout = 'vertical',+ className,}) => {return (<Linkhref={to}- className={[+ className={cn('h-full block shadow-none bg-surface-100 rounded transition','border border-transparent hover:border-overlay',- ].join(' ')}+ className+ )}>{children ? (childrendiff --git a/apps/docs/components/Extensions/index.tsx b/apps/docs/components/Extensions/index.tsxindex e2debfda82f..466582bc117 100644--- a/apps/docs/components/Extensions/index.tsx+++ b/apps/docs/components/Extensions/index.tsx@@ -1,3 +1,5 @@+'use client'+import { lazy, Suspense } from 'react'const ExtensionsInternal = lazy(() => import('./Extensions'))diff --git a/apps/docs/components/Feedback/Feedback.tsx b/apps/docs/components/Feedback/Feedback.tsxindex 3b86b5dabe1..cd0a6341f8b 100644--- a/apps/docs/components/Feedback/Feedback.tsx+++ b/apps/docs/components/Feedback/Feedback.tsx@@ -74,7 +74,7 @@ function Feedback() {const [modalOpen, setModalOpen] = useState(false)const feedbackButtonRef = useRef<HTMLButtonElement>(null)- const pathname = usePathname()+ const pathname = usePathname() ?? ''const sendTelemetryEvent = useSendTelemetryEvent()const { mutate: sendFeedbackComment } = useSendFeedbackMutation()const supabase = useSupabaseClient<Database>()diff --git a/apps/docs/components/GuidesTableOfContents.tsx b/apps/docs/components/GuidesTableOfContents.tsxindex 1125f974076..40d368a0f5b 100644--- a/apps/docs/components/GuidesTableOfContents.tsx+++ b/apps/docs/components/GuidesTableOfContents.tsx@@ -1,3 +1,5 @@+'use client'+import { usePathname } from 'next/navigation'import { useEffect, useState } from 'react'import { cn } from 'ui'@@ -20,7 +22,7 @@ const formatSlug = (slug: string) => {const formatTOCHeader = (content: string) => {let begin = false- const res = []+ const res: Array<string> = []for (const x of content) {if (x === '`') {if (!begin) {@@ -52,17 +54,24 @@ const useTocRerenderTrigger = () => {return toggleRenderFlag}+interface TOCHeader {+ id?: string+ text: string+ link: string+ level: number+}+const GuidesTableOfContents = ({className,overrideToc,video,}: {className?: string- overrideToc?: Array<{ text: string; link: string; level: number }>+ overrideToc?: Array<TOCHeader>video?: string}) => {useSubscribeTocRerender()- const [tocList, setTocList] = useState([])+ const [tocList, setTocList] = useState<TOCHeader[]>([])const pathname = usePathname()const [hash] = useHash()@@ -87,9 +96,10 @@ const GuidesTableOfContents = ({if (!link) return nullconst level = heading.tagName === 'H2' ? 2 : 3- return { text, link, level }++ return { text, link, level } as Partial<TOCHeader>})- .filter(Boolean)+ .filter((x): x is TOCHeader => !!x.text && !!x.link && !!x.level)setTocList(newHeadings)})@@ -140,3 +150,4 @@ const GuidesTableOfContents = ({export default GuidesTableOfContentsexport { useTocRerenderTrigger }+export type { TOCHeader }diff --git a/apps/docs/components/JwtGenerator/index.tsx b/apps/docs/components/JwtGenerator/index.tsxindex 0896688868a..d104d40a779 100644--- a/apps/docs/components/JwtGenerator/index.tsx+++ b/apps/docs/components/JwtGenerator/index.tsx@@ -1,3 +1,5 @@+'use client'+import dynamic from 'next/dynamic'import { Suspense } from 'react'diff --git a/apps/docs/components/MDX/partials.tsx b/apps/docs/components/MDX/partials.tsxnew file mode 100644index 00000000000..982846bd40d--- /dev/null+++ b/apps/docs/components/MDX/partials.tsx@@ -0,0 +1,27 @@+'use client'++import AuthRateLimits from './auth_rate_limits.mdx'+import DatabaseSetup from './database_setup.mdx'+import GetSessionWarning from './get_session_warning.mdx'+import HuggingFaceDeployment from './ai/quickstart_hf_deployment.mdx'+import KotlinProjectSetup from './kotlin_project_setup.mdx'+import MigrationWarnings from './migration_warnings.mdx'+import OAuthPkceFlow from './oauth_pkce_flow.mdx'+import ProjectSetup from './project_setup.mdx'+import QuickstartIntro from './quickstart_intro.mdx'+import SocialProviderSettingsSupabase from './social_provider_settings_supabase.mdx'+import SocialProviderSetup from './social_provider_setup.mdx'++export {+ AuthRateLimits,+ DatabaseSetup,+ GetSessionWarning,+ HuggingFaceDeployment,+ KotlinProjectSetup,+ MigrationWarnings,+ ProjectSetup,+ OAuthPkceFlow,+ QuickstartIntro,+ SocialProviderSettingsSupabase,+ SocialProviderSetup,+}diff --git a/apps/docs/components/Mermaid/index.tsx b/apps/docs/components/Mermaid/index.tsxindex b73a5d8033d..784ad81bf51 100644--- a/apps/docs/components/Mermaid/index.tsx+++ b/apps/docs/components/Mermaid/index.tsx@@ -1,3 +1,5 @@+'use client'+import { Suspense, lazy } from 'react'const MermaidHeavy = lazy(() => import('./Mermaid'))diff --git a/apps/docs/components/Navigation/NavigationMenu/HomeMenuIconPicker.tsx b/apps/docs/components/Navigation/NavigationMenu/HomeMenuIconPicker.tsxindex 138e0d30f36..af631de7015 100644--- a/apps/docs/components/Navigation/NavigationMenu/HomeMenuIconPicker.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/HomeMenuIconPicker.tsx@@ -28,7 +28,7 @@ import {IconMenuDevCli,} from './HomeMenuIcons'-function getMenuIcon(menuKey: string, width: number = 16, height: number = 16, className: string) {+function getMenuIcon(menuKey: string, width: number = 16, height: number = 16, className?: string) {switch (menuKey) {case 'home':return <IconMenuHome width={width} height={height} className={className} />diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsxindex 3b8556bd348..610050fd019 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx@@ -247,7 +247,9 @@ function getMenuById(id: MenuId) {return menus.find((menu) => menu.id === id) ?? menus.find((menu) => menu.id === MenuId.Home)}-function getMenuElement(menu: Menu) {+function getMenuElement(menu: Menu | undefined) {+ if (!menu) throw Error('No menu found for this menuId')+const menuType = menu.typeswitch (menuType) {case 'home':diff --git a/apps/docs/components/Navigation/SideBar.tsx b/apps/docs/components/Navigation/SideBar.tsxindex e1b957d095e..5ebb66b82de 100644--- a/apps/docs/components/Navigation/SideBar.tsx+++ b/apps/docs/components/Navigation/SideBar.tsx@@ -1,6 +1,6 @@import Link from 'next/link'import Image from 'next/legacy/image'-import { useRouter } from 'next/router'+import { usePathname } from 'next/navigation'import { IconChevronRight, IconArrowLeft } from '~/../../packages/ui'import { REFERENCES } from './NavigationMenu/NavigationMenu.constants'@@ -8,8 +8,8 @@ import { NavMenuGroup, NavMenuSection } from './Navigation.types'import * as Accordion from '@radix-ui/react-accordion'const SideBar = ({ menuItems = [] }: { menuItems: any }) => {- const { asPath } = useRouter()- const pathSegments = asPath.split('/')+ const pathname = usePathname()+ const pathSegments = pathname.split('/')const isInReferencePages = pathSegments.includes('reference') && pathSegments.length >= 3const referenceMeta = pathSegments.length >= 3 ? REFERENCES[pathSegments[2]] : undefined@@ -18,11 +18,11 @@ const SideBar = ({ menuItems = [] }: { menuItems: any }) => {const foundItem = group.items.find((section) => {if (section.items.length > 0) {const foundSubItem = section.items.find((item) => {- if (item.url === asPath) return item+ if (item.url === pathname) return item})if (foundSubItem) return section} else {- if (section.url === asPath) return section+ if (section.url === pathname) return section}})if (foundItem) return group@@ -35,7 +35,7 @@ const SideBar = ({ menuItems = [] }: { menuItems: any }) => {return undefined} else {return section.items.find((item) => {- if (item.url === asPath) return item+ if (item.url === pathname) return item})}})@@ -79,7 +79,7 @@ const SideBar = ({ menuItems = [] }: { menuItems: any }) => {className={['py-1.5 px-5 rounded text-sm transition',`${- item.url === asPath+ item.url === pathname? 'bg-background text-brand-link': 'text-foreground-light hover:text-foreground'}`,@@ -118,7 +118,7 @@ const SideBar = ({ menuItems = [] }: { menuItems: any }) => {className={['py-1.5 px-5 rounded text-sm transition',`${- section.url === asPath+ section.url === pathname? 'bg-background text-brand': 'text-foreground-light hover:text-foreground'}`,@@ -156,7 +156,7 @@ const SideBar = ({ menuItems = [] }: { menuItems: any }) => {className={['py-1.5 ml-4 px-5 rounded text-sm transition',`${- item.url === asPath+ item.url === pathname? 'bg-background text-brand': 'text-foreground-light hover:text-foreground'}`,diff --git a/apps/docs/components/ProjectConfigVariables/ProjectConfigVariables.tsx b/apps/docs/components/ProjectConfigVariables/ProjectConfigVariables.tsxindex a9f18ad4e30..638218e3f06 100644--- a/apps/docs/components/ProjectConfigVariables/ProjectConfigVariables.tsx+++ b/apps/docs/components/ProjectConfigVariables/ProjectConfigVariables.tsx@@ -1,3 +1,5 @@+'use client'+import { useIsLoggedIn, useIsUserLoading } from 'common'import Link from 'next/link'import { useEffect, useMemo } from 'react'diff --git a/apps/docs/components/RealtimeLimitsEstimator/index.tsx b/apps/docs/components/RealtimeLimitsEstimator/index.tsxindex 34fe3d20a42..aaabdd71fb0 100644--- a/apps/docs/components/RealtimeLimitsEstimator/index.tsx+++ b/apps/docs/components/RealtimeLimitsEstimator/index.tsx@@ -1,3 +1,5 @@+'use client'+import { lazy, Suspense } from 'react'const Estimator = lazy(() => import('./RealtimeLimitsEstimator'))diff --git a/apps/docs/components/RefVersionDropdown.tsx b/apps/docs/components/RefVersionDropdown.tsxindex dbe99840640..19c92b28898 100644--- a/apps/docs/components/RefVersionDropdown.tsx+++ b/apps/docs/components/RefVersionDropdown.tsx@@ -1,4 +1,4 @@-import { useRouter } from 'next/router'+import { usePathname, useRouter } from 'next/navigation'import {Badge,DropdownMenu,@@ -11,8 +11,9 @@ import {import { REFERENCES } from './Navigation/NavigationMenu/NavigationMenu.constants'const RevVersionDropdown = () => {- const { asPath, push } = useRouter()- const pathSegments = asPath.split('/')+ const pathname = usePathname()+ const { push } = useRouter()+ const pathSegments = pathname.split('/')const library = pathSegments.length >= 3 ? pathSegments[2] : undefinedconst libraryMeta = REFERENCES?.[library] ?? undefineddiff --git a/apps/docs/components/StepHikeCompact/index.tsx b/apps/docs/components/StepHikeCompact/index.tsxindex fd346c00711..a20e5f8d4bb 100644--- a/apps/docs/components/StepHikeCompact/index.tsx+++ b/apps/docs/components/StepHikeCompact/index.tsx@@ -1,4 +1,3 @@-//import { Step } from 'next-seo/lib/types'import { FC, PropsWithChildren } from 'react'import { cn } from 'ui'diff --git a/apps/docs/components/index.tsx b/apps/docs/components/index.tsxindex 620513e9522..12cebd30057 100644--- a/apps/docs/components/index.tsx+++ b/apps/docs/components/index.tsx@@ -7,7 +7,7 @@ import Link from 'next/link'import { Accordion, Admonition, Alert, Button, CodeBlock, Image, markdownComponents } from 'ui'import { GlassPanel } from 'ui-patterns/GlassPanel'import { IconPanel } from 'ui-patterns/IconPanel'-import { TabPanel, Tabs } from '~/components/Tabs'+import { TabPanel, Tabs } from '~/features/ui/Tabs'// Common componentsimport { CH } from '@code-hike/mdx/components'diff --git a/apps/docs/components/reference/ApiOperationSection.tsx b/apps/docs/components/reference/ApiOperationSection.tsxindex f6911560c9c..e1bb2f03efc 100644--- a/apps/docs/components/reference/ApiOperationSection.tsx+++ b/apps/docs/components/reference/ApiOperationSection.tsx@@ -1,7 +1,7 @@import { CodeBlock } from 'ui'import Param from '~/components/Params'+import { Tabs, TabPanel } from '~/features/ui/Tabs'import RefSubLayout from '~/layouts/ref/RefSubLayout'-import { Tabs, TabPanel } from '~/components/Tabs'import { ReactMarkdown } from 'react-markdown/lib/react-markdown'const ApiOperationSection = (props) => {diff --git a/apps/docs/components/reference/CLICommandSection.tsx b/apps/docs/components/reference/CLICommandSection.tsxindex 6997aeaca7c..94540d42299 100644--- a/apps/docs/components/reference/CLICommandSection.tsx+++ b/apps/docs/components/reference/CLICommandSection.tsx@@ -1,10 +1,10 @@import ReactMarkdown from 'react-markdown'import { CodeBlock, IconChevronRight } from 'ui'-import spec from '~/spec/cli_v1_commands.yaml' assert { type: 'yml' }import Options from '~/components/Options'import Param from '~/components/Params'-import { Tabs, TabPanel } from '~/components/Tabs'+import { Tabs, TabPanel } from '~/features/ui/Tabs'import RefSubLayout from '~/layouts/ref/RefSubLayout'+import spec from '~/spec/cli_v1_commands.yaml' assert { type: 'yml' }import RefDetailCollapse from './RefDetailCollapse'export type Flag = {diff --git a/apps/docs/components/reference/OldVersionAlert.tsx b/apps/docs/components/reference/OldVersionAlert.tsxindex 993dbd0fb4d..d1f1c28e86a 100644--- a/apps/docs/components/reference/OldVersionAlert.tsx+++ b/apps/docs/components/reference/OldVersionAlert.tsx@@ -1,6 +1,7 @@import Link from 'next/link'-import { useRouter } from 'next/router'+import { usePathname } from 'next/navigation'import { Admonition } from 'ui-patterns/admonition'+import { useMenuActiveRefId } from '~/hooks/useMenuState'import { ICommonSection } from './Reference.types'@@ -9,13 +10,13 @@ export interface OldVersionAlertProps {}const OldVersionAlert = ({ sections }: OldVersionAlertProps) => {- const router = useRouter()+ const pathname = usePathname()const activeRefId = useMenuActiveRefId()const activeSection = sections.find(({ id }) => id === activeRefId)// Remove the version number from URL to get the latest- const latestVersionUrl = router.asPath+ const latestVersionUrl = pathname.split('/').slice(0, -2).concat(activeSection ? [activeSection.slug] : [])diff --git a/apps/docs/components/reference/RefSEO.tsx b/apps/docs/components/reference/RefSEO.tsxindex 237ecec3f15..6a468b713c3 100644--- a/apps/docs/components/reference/RefSEO.tsx+++ b/apps/docs/components/reference/RefSEO.tsx@@ -1,5 +1,5 @@import { NextSeo } from 'next-seo'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'function RefSEO({ title }) {const router = useRouter()diff --git a/apps/docs/components/reference/RefSectionHandler.tsx b/apps/docs/components/reference/RefSectionHandler.tsxindex b3b189c9ce0..7ab81c7554b 100644--- a/apps/docs/components/reference/RefSectionHandler.tsx+++ b/apps/docs/components/reference/RefSectionHandler.tsx@@ -1,5 +1,5 @@+import { useRouter } from 'next/compat/router'import Head from 'next/head'-import { useRouter } from 'next/router'import { useEffect } from 'react'import { type MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/content/guides/api/sql-to-rest.mdx b/apps/docs/content/guides/api/sql-to-rest.mdxindex 4884c7d80e9..e96e844932b 100644--- a/apps/docs/content/guides/api/sql-to-rest.mdx+++ b/apps/docs/content/guides/api/sql-to-rest.mdx@@ -14,19 +14,17 @@ PostgREST supports a subset of SQL, so not all SQL queries will translate.</Admonition><SqlToRest- defaultValue={stripIndent`- select- title,- description- from- books- where- description ilike '%cheese%'- order by- title desc- limit- 5- offset- 10- `}+ defaultValue={`select+ title,+ description+from+ books+where+ description ilike '%cheese%'+order by+ title desc+limit+ 5+offset+ 10`}/>diff --git a/apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx b/apps/docs/content/guides/auth/auth-helpers/auth-ui.mdxindex c45b58f4bef..8898fd846eb 100644--- a/apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx+++ b/apps/docs/content/guides/auth/auth-helpers/auth-ui.mdx@@ -42,7 +42,7 @@ This renders the Auth component without any styling.We recommend using one of the predefined themes to style the UI.Import the theme you want to use and pass it to the `appearance.theme` prop.-```js mark=4,16 /src/index.js+```jsimport { Auth } from '@supabase/auth-ui-react'import {// Import predefined theme@@ -67,7 +67,7 @@ const App = () => (The Auth component also supports login with [official social providers](../../auth#providers).-```js mark=11 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'import { ThemeSupa } from '@supabase/auth-ui-shared'@@ -146,7 +146,7 @@ There are several ways to customize Auth UI:Auth UI comes with several themes to customize the appearance. Each predefined theme comes with at least two variations, a `default` variation, and a `dark` variation. You can switch between these themes using the `theme` prop. Import the theme you want to use and pass it to the `appearance.theme` prop.-```js mark=3,14 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'import { ThemeSupa } from '@supabase/auth-ui-shared'@@ -175,7 +175,7 @@ Currently there is only one predefined theme available, but we plan to add more.Auth UI comes with two theme variations: `default` and `dark`. You can switch between these themes with the `theme` prop.-```js mark=15 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'import { ThemeSupa } from '@supabase/auth-ui-shared'@@ -201,7 +201,7 @@ If you don't pass a value to `theme` it uses the `"default"` theme. You can passAuth UI themes can be overridden using variable tokens. See the [list of variable tokens](https://github.com/supabase/auth-ui/blob/main/packages/shared/src/theming/Themes.ts).-```js mark=12:19 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'import { ThemeSupa } from '@supabase/auth-ui-shared'@@ -335,7 +335,7 @@ const App = () => (You can use custom labels with `localization.variables` like so:-```js mark=10:15 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'@@ -461,7 +461,7 @@ Currently, translating error messages (e.g. "Invalid credentials") is not supporYou can hide links by setting the `showLinks` prop to `false`-```js mark=9 /src/index.js+```jsimport { createClient } from '@supabase/supabase-js'import { Auth } from '@supabase/auth-ui-react'diff --git a/apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx b/apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdxindex b24639e091d..85fcaee1b36 100644--- a/apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx+++ b/apps/docs/content/guides/auth/auth-helpers/nextjs-pages.mdx@@ -20,7 +20,7 @@ The `auth-helpers` package has been replaced with the `@supabase/ssr` package. WclassName="text-foreground-light border-b mt-8 pb-2">- <Accordion.Item+ <AccordionItemheader="See legacy docs"id="legacy-docs">@@ -97,7 +97,7 @@ function MyApp({ Component, pageProps }) {Wrap your `pages/_app.tsx` component with the `SessionContextProvider` component:-```tsx mark=2,8 pages/_app.tsx+```tsximport { type AppProps } from 'next/app'import { createPagesBrowserClient } from '@supabase/auth-helpers-nextjs'import { SessionContextProvider, Session } from '@supabase/auth-helpers-react'@@ -238,7 +238,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {For [row level security](/docs/learn/auth-deep-dive/auth-row-level-security) to work properly when fetching data client-side, you need to make sure to use the `supabaseClient` from the `useSupabaseClient` hook and only run your query once the user is defined client-side in the `useUser()` hook:-```jsx mark=10:17+```jsximport { Auth } from '@supabase/auth-ui-react'import { ThemeSupa } from '@supabase/auth-ui-shared'import { useUser, useSupabaseClient } from '@supabase/auth-helpers-react'@@ -933,6 +933,6 @@ import { Database } from '../database.types'const supabaseClient = useSupabaseClient<Database>()```-</Accordion.Item>+</AccordionItem></Accordion>diff --git a/apps/docs/content/guides/auth/auth-helpers/nextjs.mdx b/apps/docs/content/guides/auth/auth-helpers/nextjs.mdxindex 1d14e693b24..a6d7b1dd996 100644--- a/apps/docs/content/guides/auth/auth-helpers/nextjs.mdx+++ b/apps/docs/content/guides/auth/auth-helpers/nextjs.mdx@@ -20,7 +20,7 @@ The `auth-helpers` package has been replaced with the `@supabase/ssr` package. WclassName="text-foreground-light border-b mt-8 pb-2">- <Accordion.Item+ <AccordionItemheader="See legacy docs"id="legacy-docs">@@ -1327,6 +1327,6 @@ export default function() {For an example of creating multiple Supabase clients, check [Singleton section](/docs/guides/auth/auth-helpers/nextjs#singleton) above.-</Accordion.Item>+</AccordionItem></Accordion>diff --git a/apps/docs/content/guides/auth/auth-helpers/remix.mdx b/apps/docs/content/guides/auth/auth-helpers/remix.mdxindex dd9d537f960..85721924341 100644--- a/apps/docs/content/guides/auth/auth-helpers/remix.mdx+++ b/apps/docs/content/guides/auth/auth-helpers/remix.mdx@@ -20,7 +20,7 @@ We generally recommend using the new `@supabase/ssr` package instead of `auth-heclassName="text-foreground-light border-b mt-8 pb-2">- <Accordion.Item+ <AccordionItemheader="See legacy docs"id="legacy-docs">@@ -833,6 +833,6 @@ supabaseClient.auth.signUp({})```-</Accordion.Item>+</AccordionItem></Accordion>diff --git a/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx b/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdxindex 6fcdb70efe2..03fea2dc2b2 100644--- a/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx+++ b/apps/docs/content/guides/auth/auth-helpers/sveltekit.mdx@@ -20,7 +20,7 @@ We generally recommend using the new `@supabase/ssr` package instead of `auth-heclassName="text-foreground-light border-b mt-8 pb-2">- <Accordion.Item+ <AccordionItemheader="See legacy docs"id="legacy-docs">@@ -2031,6 +2031,6 @@ export const GET: RequestHandler = withAuth(async ({ session, getSupabaseClient- [Auth Helpers Source code](https://github.com/supabase/auth-helpers)- [SvelteKit example](https://github.com/supabase/auth-helpers/tree/main/examples/sveltekit)-</Accordion.Item>+</AccordionItem></Accordion>diff --git a/apps/docs/content/guides/auth/server-side/nextjs.mdx b/apps/docs/content/guides/auth/server-side/nextjs.mdxindex f240a9bb205..e2bc381b5ef 100644--- a/apps/docs/content/guides/auth/server-side/nextjs.mdx+++ b/apps/docs/content/guides/auth/server-side/nextjs.mdx@@ -74,7 +74,7 @@ Create a `utils/supabase` folder with a file for each type of client. Then copyclassName="text-foreground-light mt-8 mb-6"><div className="border-b mt-3 pb-3">- <Accordion.Item+ <AccordionItemheader={<span className="text-foreground">What does the `cookies` object do?</span>}id="utility-cookies">@@ -85,11 +85,11 @@ Create a `utils/supabase` folder with a file for each type of client. Then copyThe cookie is named `sb-<project_ref>-auth-token` by default.- </Accordion.Item>+ </AccordionItem></div><div className="border-b mt-3 pb-3">- <Accordion.Item+ <AccordionItemheader={<span className="text-foreground">Do I need to create a new client for every route?</span>}id="client-deduplication">@@ -99,7 +99,7 @@ Create a `utils/supabase` folder with a file for each type of client. Then copy- On the server, it basically configures a `fetch` call. You need to reconfigure the fetch call anew for every request to your server, because you need the cookies from the request.- On the client, `createBrowserClient` already uses a singleton pattern, so you only ever create one instance, no matter how many times you call your `createClient` function.- </Accordion.Item>+ </AccordionItem></div></Accordion>@@ -580,7 +580,7 @@ Create a `utils/supabase` folder with a file for each type of client. Then copyclassName="text-foreground-light mt-8 mb-6"><div className="border-b pb-3">- <Accordion.Item+ <AccordionItemheader={<span className="text-foreground">Why do I need so many types of clients?</span>}id="nextjs-clients">@@ -592,11 +592,11 @@ Create a `utils/supabase` folder with a file for each type of client. Then copy- **Component** - Runs on the client. Reads cookies from browser storage. Behind the scenes, `createBrowserClient` reuses the same client instance if called multiple times, so don't worry about deduplicating the client yourself.- **API route** - Runs on the server. Reads cookies from the request, which is passed through from `NextApiRequest`.- </Accordion.Item>+ </AccordionItem></div><div className="border-b mt-3 pb-3">- <Accordion.Item+ <AccordionItemheader={<span className="text-foreground">What does the `cookies` object do?</span>}id="client-storage-cookies">@@ -605,7 +605,7 @@ Create a `utils/supabase` folder with a file for each type of client. Then copyThe cookie is named `sb-<project_ref>-auth-token` by default.- </Accordion.Item>+ </AccordionItem></div></Accordion>diff --git a/apps/docs/content/guides/functions/auth.mdx b/apps/docs/content/guides/functions/auth.mdxindex f607c3587ed..639e667ff34 100644--- a/apps/docs/content/guides/functions/auth.mdx+++ b/apps/docs/content/guides/functions/auth.mdx@@ -11,7 +11,7 @@ Edge Functions work seamlessly with [Supabase Auth](/docs/guides/auth).When a user makes a request to an Edge Function, you can use the Authorization header to set the Auth context in the Supabase client:-```js mark=9+```jsimport { createClient } from 'jsr:@supabase/supabase-js@2'Deno.serve(async (req: Request) => {@@ -32,7 +32,7 @@ Importantly, this is done _inside_ the `Deno.serve()` callback argument, so thatAfter initializing a Supabase client with the Auth context, you can use `getUser()` to fetch the user object, and run queries in the context of the user with [Row Level Security (RLS)](/docs/guides/database/postgres/row-level-security) policies enforced.-```js mark=12:13+```jsimport { createClient } from 'jsr:@supabase/supabase-js@2'Deno.serve(async (req: Request) => {@@ -60,7 +60,7 @@ Deno.serve(async (req: Request) => {After initializing a Supabase client with the Auth context, all queries will be executed with the context of the user. For database queries, this means [Row Level Security](/docs/guides/database/postgres/row-level-security) will be enforced.-```js mark=12+```jsimport { createClient } from 'jsr:@supabase/supabase-js@2'Deno.serve(async (req: Request) => {diff --git a/apps/docs/content/guides/platform/database-size.mdx b/apps/docs/content/guides/platform/database-size.mdxindex a4f46586fa0..fb4112e2c85 100644--- a/apps/docs/content/guides/platform/database-size.mdx+++ b/apps/docs/content/guides/platform/database-size.mdx@@ -36,16 +36,16 @@ Depending on your billing plan, your database can go into read-only mode which cPostgres does not immediately reclaim the physical space used by dead tuples (i.e., deleted rows) in the DB. They are marked as "removed" until a [vacuum operation](https://www.postgresql.org/docs/current/routine-vacuuming.html) is executed. As a result, deleting data from your database may not immediately reduce the reported disk usage. You can use the [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) `inspect db bloat` command to view all dead tuples in your database. Alternatively, you can run the [query](https://github.com/supabase/cli/blob/c9cce58025fded16b4c332747f819a44f45c3b83/internal/inspect/bloat/bloat.go#L17) found in the CLI's GitHub repo in the [SQL Editor](https://supabase.com/dashboard/project/_/sql/)```bash-# login to the CLI+# Login to the CLInpx supabase login-# initlize a local supabase directory+# Initialize a local supabase directorynpx supabase init-# link a project+# Link a projectnpx supabase link-# detect bloat+# Detect bloatnpx supabase inspect db bloat --linked```diff --git a/apps/docs/pages/guides/platform/exhaust-swap.mdx b/apps/docs/content/guides/platform/exhaust-swap.mdxsimilarity index 92%rename from apps/docs/pages/guides/platform/exhaust-swap.mdxrename to apps/docs/content/guides/platform/exhaust-swap.mdxindex adfb7a7a5ea..7abecd2198f 100644--- a/apps/docs/pages/guides/platform/exhaust-swap.mdx+++ b/apps/docs/content/guides/platform/exhaust-swap.mdx@@ -1,11 +1,8 @@-import Layout from '~/layouts/DefaultGuideLayout'--export const meta = {- id: 'exhaust-swap',- title: 'High swap usage',- description:- 'Learn what high Swap usage could mean for your Supabase instance and what could have caused it.',-}+---+id: 'exhaust-swap'+title: 'High swap usage'+description: 'Learn what high Swap usage could mean for your Supabase instance and what could have caused it.'+---Learn what high Swap usage means, what can cause it, and how to solve it.@@ -65,7 +62,3 @@ If you find that your RAM and Swap usage are high, you have three options:1. **Optimize performance:** Get more out of your instance's resources by optimizing your usage. See the [performance tuning guide](https://supabase.com/docs/guides/platform/performance#examining-query-performance) and our [production readiness guide](https://supabase.com/docs/guides/platform/going-into-prod#performance).2. **Upgrade your compute:** You can get a Compute Add-on for your project. Navigate to [the **Addons** section in project settings](https://supabase.com/dashboard/project/_/settings/addons?panel=computeInstance) to see your upgrade options.3. **Read Replicas:** You can spread the load on your Supabase project by creating a Read Replica. See [the read replicas guide](https://supabase.com/docs/guides/platform/read-replicas) for more information.--export const Page = ({ children }) => <Layout meta={meta} children={children} />--export default Pagediff --git a/apps/docs/content/guides/platform/logs.mdx b/apps/docs/content/guides/platform/logs.mdxindex de7b42234f4..0fb33908724 100644--- a/apps/docs/content/guides/platform/logs.mdx+++ b/apps/docs/content/guides/platform/logs.mdx@@ -293,11 +293,13 @@ Refer to the full field reference for each available source below. Do note that{(logConstants) => (<Tabs scrollable size="small" type="underlined" defaultActiveId="edge_logs" queryGroup="source">{logConstants.schemas.map((schema) => (- <TabPanel id={schema.reference} label={schema.name}>+ <TabPanel id={schema.reference} key={schema.reference} label={schema.name}><table><thead>- <td className="font-bold">Path</td>- <td className="font-bold">Type</td>+ <tr>+ <th className="font-bold">Path</th>+ <th className="font-bold">Type</th>+ </tr></thead><tbody>{schema.fieldsdiff --git a/apps/docs/features/docs/GuidesMdx.client.tsx b/apps/docs/features/docs/GuidesMdx.client.tsxnew file mode 100644index 00000000000..a6d81f4a231--- /dev/null+++ b/apps/docs/features/docs/GuidesMdx.client.tsx@@ -0,0 +1,16 @@+'use client'++/**+ * The MDXProvider is necessary so that MDX partials will have access+ * to components.+ */++import { MDXProvider } from '@mdx-js/react'+import { type PropsWithChildren } from 'react'+import { components } from '~/features/docs/mdx.shared'++const MDXProviderGuides = ({ children }: PropsWithChildren) => (+ <MDXProvider components={components}>{children}</MDXProvider>+)++export { MDXProviderGuides }diff --git a/apps/docs/features/docs/GuidesMdx.template.tsx b/apps/docs/features/docs/GuidesMdx.template.tsxnew file mode 100644index 00000000000..3d5694fe9e1--- /dev/null+++ b/apps/docs/features/docs/GuidesMdx.template.tsx@@ -0,0 +1,176 @@+import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }+import { remarkCodeHike, type CodeHikeConfig } from '@code-hike/mdx'+import { ExternalLink } from 'lucide-react'+import { type SerializeOptions } from 'next-mdx-remote/dist/types'+import { MDXRemote } from 'next-mdx-remote/rsc'+import { type ComponentProps, type ReactNode } from 'react'+import remarkGfm from 'remark-gfm'+import rehypeKatex from 'rehype-katex'+import remarkMath from 'remark-math'+import { cn } from 'ui'+import GuidesTableOfContents from '~/components/GuidesTableOfContents'+import { components } from '~/features/docs/mdx.shared'+import type { WithRequired } from '~/features/helpers.types'+import { type GuideFrontmatter } from '~/lib/docs'+import { MDXProviderGuides } from './GuidesMdx.client'++const codeHikeOptions: CodeHikeConfig = {+ theme: codeHikeTheme,+ lineNumbers: true,+ showCopyButton: true,+ skipLanguages: [],+ autoImport: false,+}++const mdxOptions: SerializeOptions = {+ mdxOptions: {+ useDynamicImport: true,+ remarkPlugins: [+ [remarkMath, { singleDollarTextMath: false }],+ remarkGfm,+ [remarkCodeHike, codeHikeOptions],+ ],+ rehypePlugins: [rehypeKatex as any],+ },+}++const MDXRemoteGuides = ({ options = {}, ...props }: ComponentProps<typeof MDXRemote>) => {+ const { mdxOptions: { remarkPlugins, rehypePlugins, ...otherMdxOptions } = {}, ...otherOptions } =+ options+ const {+ mdxOptions: {+ remarkPlugins: originalRemarkPlugins,+ rehypePlugins: originalRehypePlugins,+ ...originalMdxOptions+ } = {},+ } = mdxOptions++ const finalOptions = {+ ...mdxOptions,+ ...otherOptions,+ mdxOptions: {+ ...originalMdxOptions,+ ...otherMdxOptions,+ remarkPlugins: [...(originalRemarkPlugins ?? []), ...(remarkPlugins ?? [])],+ rehypePlugins: [...(originalRehypePlugins ?? []), ...(rehypePlugins ?? [])],+ },+ } as SerializeOptions++ return <MDXRemote components={components} options={finalOptions} {...props} />+}++const EDIT_LINK_SYMBOL = Symbol('edit link')+interface EditLink {+ [EDIT_LINK_SYMBOL]: true+ link: string+ includesProtocol: boolean+}++/**+ * Create an object representing a link where the original content can be+ * edited.+ *+ * Takes either a relative path, which will be prefixed with+ * `https://github.com/`, or a full URL including protocol.+ */+const newEditLink = (str: string): EditLink => {+ if (str.startsWith('/')) {+ throw Error(`Edit links cannot start with slashes. Received: ${str}`)+ }++ /**+ * Catch strings that provide FQDNS without https?:+ *+ * At the start of a string, before the first slash, there is a dot+ * surrounded by non-slash characters.+ */+ if (/^[^\/]+\.[^\/]+\//.test(str)) {+ throw Error(`Fully qualified domain names must start with 'https?'. Received: ${str}`)+ }++ return {+ [EDIT_LINK_SYMBOL]: true,+ link: str,+ includesProtocol: str.startsWith('http://') || str.startsWith('https://'),+ }+}++interface BaseGuideTemplateProps {+ meta?: GuideFrontmatter+ content?: string+ children?: ReactNode+ editLink: EditLink+ mdxOptions?: SerializeOptions+}++type GuideTemplateProps =+ | WithRequired<BaseGuideTemplateProps, 'children'>+ | WithRequired<BaseGuideTemplateProps, 'content'>++const GuideTemplate = ({ meta, content, children, editLink, mdxOptions }: GuideTemplateProps) => {+ const hideToc = meta?.hideToc || meta?.hide_table_of_contents++ return (+ <div className={'grid grid-cols-12 relative gap-4'}>+ <div+ className={cn(+ 'relative',+ 'transition-all ease-out',+ 'duration-100',+ hideToc ? 'col-span-12' : 'col-span-12 md:col-span-9'+ )}+ >+ <article+ // Used to get headings for the table of contents+ id="sb-docs-guide-main-article"+ className="prose max-w-none"+ >+ <h1 className="mb-0">{meta?.title || 'Supabase Docs'}</h1>+ {meta?.subtitle && (+ <h2 className="mt-3 text-xl text-foreground-light">{meta.subtitle}</h2>+ )}+ <hr className="not-prose border-t-0 border-b my-8" />+ <MDXProviderGuides>+ {content && <MDXRemoteGuides source={content} options={mdxOptions} />}+ </MDXProviderGuides>+ {children}+ <footer className="mt-16 not-prose">+ <a+ href={+ editLink.includesProtocol ? editLink.link : `https://github.com/${editLink.link}`+ }+ className={cn(+ 'w-fit',+ 'flex items-center gap-1',+ 'text-sm text-scale-1000 hover:text-scale-1200',+ 'transition-colors'+ )}+ target="_blank"+ rel="noreferrer noopener"+ >+ Edit this page on GitHub <ExternalLink size={14} strokeWidth={1.5} />+ </a>+ </footer>+ </article>+ </div>+ {!hideToc && (+ <GuidesTableOfContents+ video={meta?.tocVideo}+ className={cn(+ 'hidden md:block',+ 'col-span-3 self-start',+ 'sticky top-[calc(var(--header-height)+2rem)]',+ /**+ * [TODO: Charis]+ *+ * Figure out what these magic numbers represent+ */+ 'max-h-[calc(100vh-60px-5rem)]'+ )}+ />+ )}+ </div>+ )+}++export { GuideTemplate, MDXRemoteGuides, newEditLink }diff --git a/apps/docs/features/docs/GuidesMdx.utils.tsx b/apps/docs/features/docs/GuidesMdx.utils.tsxnew file mode 100644index 00000000000..1b45b259a94--- /dev/null+++ b/apps/docs/features/docs/GuidesMdx.utils.tsx@@ -0,0 +1,167 @@+import matter from 'gray-matter'+import { type Metadata, type ResolvingMetadata } from 'next'+import { redirect } from 'next/navigation'+import { watch } from 'node:fs'+import { readFile, readdir } from 'node:fs/promises'+import { extname, join, resolve, sep } from 'node:path'+import { existsFile } from '~/features/helpers.fs'+import type { OrPromise } from '~/features/helpers.types'+import { notFoundLink } from '~/features/recommendations/NotFound.utils'+import { BASE_PATH, IS_DEV, MISC_URL } from '~/lib/constants'+import { GUIDES_DIRECTORY, isValidGuideFrontmatter, type GuideFrontmatter } from '~/lib/docs'+import { newEditLink } from './GuidesMdx.template'++/**+ * [TODO Charis]+ *+ * This is kind of a dumb place for this to be, clean up later as part of+ * cleaning up navigation menus.+ */+const PUBLISHED_SECTIONS = [+ 'ai',+ 'api',+ 'auth',+ 'cli',+ 'database',+ 'functions',+ 'getting-started',+ // 'graphql', -- technically published, but completely federated+ 'platform',+ 'realtime',+ 'resources',+ 'self-hosting',+ 'storage',+] as const++const getGuidesMarkdownInternal = async ({ slug }: { slug: string[] }) => {+ const relPath = slug.join(sep).replace(/\/$/, '')+ const fullPath = join(GUIDES_DIRECTORY, relPath + '.mdx')+ /**+ * SAFETY CHECK:+ * Prevent accessing anything outside of published sections and GUIDES_DIRECTORY+ */+ if (+ !fullPath.startsWith(GUIDES_DIRECTORY) ||+ !PUBLISHED_SECTIONS.some((section) => relPath.startsWith(section))+ ) {+ redirect(notFoundLink(slug.join('/')))+ }++ let mdx: string+ try {+ mdx = await readFile(fullPath, 'utf-8')+ } catch {+ redirect(notFoundLink(slug.join('/')))+ }++ const editLink = newEditLink(+ `supabase/supabase/blob/master/apps/docs/content/guides/${relPath}.mdx`+ )++ const { data: meta, content } = matter(mdx)+ if (!isValidGuideFrontmatter(meta)) {+ throw Error('Type of frontmatter is not valid')+ }++ return {+ pathname: `/guides/${slug.join('/')}` satisfies `/${string}`,+ meta,+ content,+ editLink,+ }+}++/**+ * Caching this for the entire process is fine because the Markdown content is+ * baked into each deployment and cannot change. There's also nothing sensitive+ * here: this is just reading the public MDX files from the codebase.+ *+ * Unlike Next.js' unstable cache, this doesn't persist between deployments,+ * which we don't want because the content _will_ change.+ */+const cache = <Args extends unknown[], Output>(fn: (...args: Args) => Promise<Output>) => {+ const _cache = new Map<string, Output>()++ if (IS_DEV) {+ watch(resolve(GUIDES_DIRECTORY), { recursive: true }, (_, filename) => {+ if (!filename) return+ const cacheKey = [{ slug: filename.replace(/\.mdx$/, '').split(sep) }]+ _cache.delete(JSON.stringify(cacheKey))+ })+ }++ return async (...args: Args) => {+ const cacheKey = JSON.stringify(args)+ if (!_cache.has(cacheKey)) {+ _cache.set(cacheKey, await fn(...args))+ }+ return _cache.get(cacheKey)!+ }+}+const getGuidesMarkdown = cache(getGuidesMarkdownInternal)++const genGuidesStaticParams = (directory?: string) => async () => {+ const promises = directory+ ? (await readdir(join(GUIDES_DIRECTORY, directory), { recursive: true }))+ .filter((file) => extname(file) === '.mdx' && !file.split(sep).at(-1).startsWith('_'))+ .map((file) => ({ slug: file.replace(/\.mdx$/, '').split(sep) }))+ : PUBLISHED_SECTIONS.map(async (section) =>+ (await readdir(join(GUIDES_DIRECTORY, section), { recursive: true }))+ .filter((file) => extname(file) === '.mdx' && !file.split(sep).at(-1).startsWith('_'))+ .map((file) => ({+ slug: [section, ...file.replace(/\.mdx$/, '').split(sep)],+ }))+ .concat(+ (await existsFile(join(GUIDES_DIRECTORY, `${section}.mdx`)))+ ? [{ slug: [section] }]+ : []+ )+ )++ /**+ * Flattening earlier will not work because there is nothing to flatten+ * until the promises resolve.+ */+ const result = (await Promise.all(promises)).flat()+ return result+}++const pluckPromise = <T, K extends keyof T>(promise: Promise<T>, key: K) =>+ promise.then((data) => data[key])++const genGuideMeta =+ <Params,>(+ generate: (params: Params) => OrPromise<{ meta: GuideFrontmatter; pathname: `/${string}` }>+ ) =>+ async ({ params }: { params: Params }, parent: ResolvingMetadata): Promise<Metadata> => {+ const [parentAlternates, parentOg, { meta, pathname }] = await Promise.all([+ pluckPromise(parent, 'alternates'),+ pluckPromise(parent, 'openGraph'),+ generate(params),+ ])++ // Pathname has form `/guides/(section)/**`+ const ogType = pathname.split('/')[2]++ return {+ title: `${meta.title} | Supabase Docs`,+ description: meta.description || meta.subtitle,+ // @ts-ignore+ alternates: {+ ...parentAlternates,+ canonical: meta.canonical || `${BASE_PATH}${pathname}`,+ },+ openGraph: {+ ...parentOg,+ url: `${BASE_PATH}${pathname}`,+ images: {+ url: `${MISC_URL}/functions/v1/og-images?site=docs&type=${encodeURIComponent(ogType)}&title=${encodeURIComponent(meta.title)}&description=${encodeURIComponent(meta.description ?? 'undefined')}`,+ width: 800,+ height: 600,+ alt: meta.title,+ },+ },+ }+ }++export { getGuidesMarkdown, genGuidesStaticParams, genGuideMeta }diff --git a/apps/docs/features/docs/mdx.shared.tsx b/apps/docs/features/docs/mdx.shared.tsxnew file mode 100644index 00000000000..c6eb04ae6fa--- /dev/null+++ b/apps/docs/features/docs/mdx.shared.tsx@@ -0,0 +1,94 @@+import { ArrowDown, Check } from 'lucide-react'+import Link from 'next/link'+import { GlassPanel } from 'ui-patterns/GlassPanel'+import { IconPanel } from 'ui-patterns/IconPanel'+import SqlToRest from 'ui-patterns/SqlToRest'+import { Admonition, Button, Image } from 'ui'+import { Heading } from 'ui/src/components/CustomHTMLElements'+import { AppleSecretGenerator } from '~/components/AppleSecretGenerator'+import AuthProviders from '~/components/AuthProviders'+import { AuthSmsProviderConfig } from '~/components/AuthSmsProviderConfig'+import { CostWarning } from '~/components/AuthSmsProviderConfig/AuthSmsProviderConfig.Warnings'+import ButtonCard from '~/components/ButtonCard'+import { Extensions } from '~/components/Extensions'+import { JwtGenerator } from '~/components/JwtGenerator'+import {+ AuthRateLimits,+ DatabaseSetup,+ GetSessionWarning,+ HuggingFaceDeployment,+ KotlinProjectSetup,+ MigrationWarnings,+ ProjectSetup,+ OAuthPkceFlow,+ QuickstartIntro,+ SocialProviderSettingsSupabase,+ SocialProviderSetup,+} from '~/components/MDX/partials'+import { Mermaid } from '~/components/Mermaid'+import { NavData } from '~/components/NavData'+import { ProjectConfigVariables } from '~/components/ProjectConfigVariables'+import { RealtimeLimitsEstimator } from '~/components/RealtimeLimitsEstimator'+import { SharedData } from '~/components/SharedData'+import StepHikeCompact from '~/components/StepHikeCompact'+import { Accordion, AccordionItem } from '~/features/ui/Accordion'+import * as CH from '~/features/ui/CodeHike'+import { Tabs, TabPanel } from '~/features/ui/Tabs'++const components = {+ Accordion,+ AccordionItem,+ Admonition,+ AuthRateLimits,+ AuthSmsProviderConfig,+ AppleSecretGenerator,+ AuthProviders,+ Button,+ ButtonCard,+ CH,+ CostWarning,+ DatabaseSetup,+ Extensions,+ GetSessionWarning,+ GlassPanel,+ HuggingFaceDeployment,+ IconArrowDown: ArrowDown,+ IconCheck: Check,+ IconPanel,+ Image: (props: any) => <Image fill className="object-contain" {...props} />,+ JwtGenerator,+ KotlinProjectSetup,+ Link,+ Mermaid,+ MigrationWarnings,+ NavData,+ OAuthPkceFlow,+ ProjectConfigVariables,+ ProjectSetup,+ QuickstartIntro,+ RealtimeLimitsEstimator,+ SharedData,+ SocialProviderSettingsSupabase,+ SocialProviderSetup,+ SqlToRest,+ StepHikeCompact,+ Tabs,+ TabPanel,+ h2: (props: any) => (+ <Heading tag="h2" {...props}>+ {props.children}+ </Heading>+ ),+ h3: (props: any) => (+ <Heading tag="h3" {...props}>+ {props.children}+ </Heading>+ ),+ h4: (props: any) => (+ <Heading tag="h4" {...props}>+ {props.children}+ </Heading>+ ),+}++export { components }diff --git a/apps/docs/features/helpers.fs.ts b/apps/docs/features/helpers.fs.tsnew file mode 100644index 00000000000..f99411b7696--- /dev/null+++ b/apps/docs/features/helpers.fs.ts@@ -0,0 +1,12 @@+import { stat } from 'fs/promises'++const existsFile = async (fullPath: string) => {+ try {+ await stat(fullPath)+ return true+ } catch {+ return false+ }+}++export { existsFile }diff --git a/apps/docs/features/helpers.types.ts b/apps/docs/features/helpers.types.tsnew file mode 100644index 00000000000..200048aae30--- /dev/null+++ b/apps/docs/features/helpers.types.ts@@ -0,0 +1,5 @@+type OrPromise<T> = T | Promise<T>++type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] }++export type { OrPromise, WithRequired }diff --git a/apps/docs/features/recommendations/NotFound.client.tsx b/apps/docs/features/recommendations/NotFound.client.tsxnew file mode 100644index 00000000000..e6cbd149aa8--- /dev/null+++ b/apps/docs/features/recommendations/NotFound.client.tsx@@ -0,0 +1,69 @@+'use client'++import { type DocsSearchResult } from 'common'+import Link from 'next/link'+import { Button } from 'ui'+import { useCommandMenu } from 'ui-patterns/Cmdk'+import ButtonCard from '~/components/ButtonCard'++const NotFound = ({+ recommendations,+ omitSearch = false,+}: {+ recommendations?: Omit<DocsSearchResult, 'sections'>[] | null+ omitSearch?: boolean+}) => {+ const { setIsOpen: setCommandMenuOpen } = useCommandMenu()++ return (+ <article className="prose max-w-[80ch]">+ <h1>We couldn't find that page</h1>+ <p>+ Sorry, we couldn't find that page. It might be missing, or we had a temporary error+ generating it.+ </p>+ <div className="flex flex-wrap gap-4 pt-4">+ {!omitSearch && (+ <Button type="primary" size="small" onClick={() => setCommandMenuOpen(true)}>+ Search for page+ </Button>+ )}+ <Button type="default" size="small" className="p-4" asChild>+ <Link href="/" className="no-underline">+ Return to homepage+ </Link>+ </Button>+ <Button type="text" size="small" asChild>+ <Link+ href="https://github.com/supabase/supabase/issues/new?assignees=&labels=documentation&projects=&template=2.Improve_docs.md"+ target="_blank"+ rel="noreferrer noopener"+ className="no-underline"+ >+ Report missing page+ </Link>+ </Button>+ </div>+ {recommendations && (+ <section aria-labelledby="empty-page-recommendations" className="mt-20">+ <h2 id="empty-page-recommendations">Are you looking for...?</h2>+ <ul className="not-prose grid grid-cols-[repeat(auto-fit,minmax(300px,1fr))] gap-4">+ {recommendations+ .filter(({ title }) => !!title)+ .slice(0, 6)+ .map(({ path, title, subtitle, description }) => (+ <ButtonCard+ key={path}+ to={path}+ title={title}+ description={subtitle || description || undefined}+ />+ ))}+ </ul>+ </section>+ )}+ </article>+ )+}++export { NotFound }diff --git a/apps/docs/features/recommendations/NotFound.utils.ts b/apps/docs/features/recommendations/NotFound.utils.tsnew file mode 100644index 00000000000..19774150840--- /dev/null+++ b/apps/docs/features/recommendations/NotFound.utils.ts@@ -0,0 +1,8 @@+const notFoundLink = (origPath: string) => {+ if (!origPath) return '/not-found'++ const searchParams = new URLSearchParams({ page: origPath })+ return `/not-found?${searchParams}`+}++export { notFoundLink }diff --git a/apps/docs/features/ui/Accordion.tsx b/apps/docs/features/ui/Accordion.tsxnew file mode 100644index 00000000000..dea771bb5a4--- /dev/null+++ b/apps/docs/features/ui/Accordion.tsx@@ -0,0 +1,13 @@+'use client'++import { Accordion as AccordionPrimitive } from 'ui'++/**+ * This makes the component work in MDX files, which otherwise would error on+ * "trying to dot into a Client Component".+ */++const Accordion = AccordionPrimitive+const AccordionItem = AccordionPrimitive.Item++export { Accordion, AccordionItem }diff --git a/apps/docs/features/ui/CodeHike.tsx b/apps/docs/features/ui/CodeHike.tsxnew file mode 100644index 00000000000..c54dbba339d--- /dev/null+++ b/apps/docs/features/ui/CodeHike.tsx@@ -0,0 +1,28 @@+'use client'++import { CH } from '@code-hike/mdx/components'++/**+ * [Charis 2024-04-20]+ *+ * Annotations are broken and I can't find a way around it.+ *+ * Problem seems to be related to CH.annotations being a map of components and+ * not a component itself. It's not bundled by the RSC bundler, and you get the+ * error `Could not find the module .../CodeHike.tsx#annotations#mark in the+ * React Client Manifest`.+ */++export const Code = CH.Code+export const Section = CH.Section+export const SectionLink = CH.SectionLink+export const SectionCode = CH.SectionCode+export const Spotlight = CH.Spotlight+export const Scrollycoding = CH.Scrollycoding+export const Preview = CH.Preview+export const Annotation = CH.Annotation+export const Slideshow = CH.Slideshow+export const InlineCode = CH.InlineCode+export const CodeSlot = CH.CodeSlot+export const PreviewSlot = CH.PreviewSlot+export const StaticToggle = CH.StaticTogglediff --git a/apps/docs/components/Tabs.tsx b/apps/docs/features/ui/Tabs.tsxsimilarity index 100%rename from apps/docs/components/Tabs.tsxrename to apps/docs/features/ui/Tabs.tsxdiff --git a/apps/docs/layouts/guides/index.tsx b/apps/docs/layouts/guides/index.tsxindex 1c510cd3315..dd785a54b31 100644--- a/apps/docs/layouts/guides/index.tsx+++ b/apps/docs/layouts/guides/index.tsx@@ -1,21 +1,16 @@-import { MDXProvider } from '@mdx-js/react'+'use client'+import 'katex/dist/katex.min.css'-import { ExternalLink } from 'lucide-react'-import { NextSeo } from 'next-seo'-import { useRouter } from 'next/router'-import { type FC } from 'react'-import { cn } from 'ui'+import { type FC } from 'react'-import components from '~/components'import { FooterHelpCalloutType } from '~/components/FooterHelpCallout'-import GuidesTableOfContents from '~/components/GuidesTableOfContents'import { type MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'import { LayoutMainContent } from '~/layouts/DefaultLayout'import { MainSkeleton } from '~/layouts/MainSkeleton'interface Props {- meta: {+ meta?: {title: stringdescription?: string // used in meta tagshide_table_of_contents?: boolean@@ -35,121 +30,12 @@ interface Props {}const Layout: FC<Props> = (props) => {- const { asPath } = useRouter()- const router = useRouter()-const menuId = props.menuId- const EDIT_BUTTON_EXCLUDE_LIST = ['/404']-- // page type, ie, Auth, Database, Storage etc- const ogPageType = asPath.split('/')[2]- // open graph image url constructor- const ogImageUrl = encodeURI(- `https://obuldanrptloktxcffvn.supabase.co/functions/v1/og-images?site=docs${- ogPageType ? `&type=${ogPageType}` : ''- }&title=${encodeURIComponent(props.meta?.title)}&description=${encodeURIComponent(props.meta?.description)}`- )-return (<>- <NextSeo- title={`${props.meta?.title} | Supabase Docs`}- canonical={props.meta?.canonical ?? `https://supabase.com/docs${asPath}`}- openGraph={{- url: `https://supabase.com/docs${asPath}`,- type: 'article',- siteName: 'Supabase',- title: `${props.meta?.title} | Supabase Docs`,- description: props.meta?.description,- images: [- {- url: ogImageUrl,- width: 800,- height: 600,- alt: props.meta?.title,- },- ],- videos: props.meta?.video && [- {- // youtube based video meta- url: props.meta?.video,- width: 640,- height: 385,- type: 'application/x-shockwave-flash',- },- ],- article: {- publishedTime: new Date().toISOString(),- modifiedTime: new Date().toISOString(),- authors: ['Supabase'],- },- }}- twitter={{- cardType: 'summary_large_image',- site: '@supabase',- handle: '@supabase',- }}- /><MainSkeleton menuId={menuId}>- <LayoutMainContent className="pb-0">- <div className={['grid grid-cols-12 relative gap-4'].join(' ')}>- <div- className={[- 'relative',- !props.hideToc ? 'col-span-12 md:col-span-9' : 'col-span-12',- 'transition-all ease-out',- 'duration-100',- ].join(' ')}- >- {props.meta?.breadcrumb && (- <p className="text-brand tracking-wider mb-3">{props.meta.breadcrumb}</p>- )}- <article- // Used to get headings for the table of contents- id="sb-docs-guide-main-article"- className="prose max-w-none"- >- <h1 className="mb-0">{props.meta.title}</h1>- {props.meta?.subtitle && (- <h2 className="mt-3 text-xl text-foreground-light">{props.meta.subtitle}</h2>- )}- <div className="w-full border-b my-8"></div>- <MDXProvider components={components}>{props.children}</MDXProvider>-- {EDIT_BUTTON_EXCLUDE_LIST.includes(router.route) ? (- <></>- ) : (- <div className="mt-16 not-prose">- <div>- <a- href={`https://github.com/${- props.editLink ||- `supabase/supabase/edit/master/apps/docs/pages${router.asPath}.mdx`- }- `}- className="text-sm transition flex items-center gap-1 text-scale-1000 hover:text-scale-1200 w-fit"- >- Edit this page on GitHub <ExternalLink size={14} strokeWidth={1.5} />- </a>- </div>- </div>- )}- </article>- </div>- {!props.hideToc && !props.meta?.hide_table_of_contents && (- <GuidesTableOfContents- video={props.meta?.tocVideo}- className={cn(- 'col-span-3 self-start',- 'hidden md:block md:col-span-3',- 'sticky top-[calc(var(--header-height,40px)+2rem)]',- 'max-h-[calc(100vh-60px-5rem)]'- )}- />- )}- </div>- </LayoutMainContent>+ <LayoutMainContent className="pb-0">{props.children}</LayoutMainContent></MainSkeleton></>)diff --git a/apps/docs/layouts/ref/RefSubLayout.tsx b/apps/docs/layouts/ref/RefSubLayout.tsxindex 69a91fc1db3..b0063ffa4f1 100644--- a/apps/docs/layouts/ref/RefSubLayout.tsx+++ b/apps/docs/layouts/ref/RefSubLayout.tsx@@ -1,7 +1,7 @@import { useInView } from 'react-intersection-observer'import { FC, PropsWithChildren } from 'react'import { highlightSelectedNavItem } from 'ui/src/components/CustomHTMLElements/CustomHTMLElements.utils'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import { useNavigationMenuContext } from '~/components/Navigation/NavigationMenu/NavigationMenu.Context'import { menuState } from '~/hooks/useMenuState'import Image from 'next/legacy/image'diff --git a/apps/docs/layouts/ref/RefSubLayoutNonFunc.tsx b/apps/docs/layouts/ref/RefSubLayoutNonFunc.tsxindex b31b8260e68..aa1ad6c9f69 100644--- a/apps/docs/layouts/ref/RefSubLayoutNonFunc.tsx+++ b/apps/docs/layouts/ref/RefSubLayoutNonFunc.tsx@@ -1,7 +1,7 @@import { useInView } from 'react-intersection-observer'import { FC, PropsWithChildren } from 'react'import { highlightSelectedNavItem } from 'ui/src/components/CustomHTMLElements/CustomHTMLElements.utils'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import { useNavigationMenuContext } from '~/components/Navigation/NavigationMenu/NavigationMenu.Context'import { menuState } from '~/hooks/useMenuState'diff --git a/apps/docs/lib/constants.ts b/apps/docs/lib/constants.tsindex 53c1ad2bd59..d146d838284 100644--- a/apps/docs/lib/constants.ts+++ b/apps/docs/lib/constants.ts@@ -1,10 +1,12 @@export const API_URL = (process.env.NODE_ENV === 'development'? process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080'- : process.env.NEXT_PUBLIC_API_URL+ : process.env.NEXT_PUBLIC_API_URL!).replace(/\/platform$/, '')export const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH || '/docs'export const BUILD_PREVIEW_HTML = process.env.NEXT_PUBLIC_BUILD_PREVIEW_HTML === 'true'+export const IS_DEV = process.env.NODE_ENV === 'development'export const IS_PLATFORM = process.env.NEXT_PUBLIC_IS_PLATFORM === 'true'export const IS_PREVIEW = process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'export const LOCAL_SUPABASE = process.env.NEXT_PUBLIC_LOCAL_SUPABASE === 'true'+export const MISC_URL = process.env.NEXT_PUBLIC_MISC_URL ?? ''diff --git a/apps/docs/lib/docs.ts b/apps/docs/lib/docs.tsindex 6481e58f3cf..ecda299a499 100644--- a/apps/docs/lib/docs.ts+++ b/apps/docs/lib/docs.ts@@ -15,10 +15,14 @@ import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }const DOCS_DIRECTORY = join(dirname(fileURLToPath(import.meta.url)), '..')export const GUIDES_DIRECTORY = join(DOCS_DIRECTORY, 'content/guides')-type GuideFrontmatter = {+export type GuideFrontmatter = {title: string+ subtitle?: stringdescription?: string+ canonical?: stringhideToc?: boolean+ // @deprecated+ hide_table_of_contents?: booleantocVideo?: string}@@ -34,11 +38,28 @@ export function isValidGuideFrontmatter(obj: object): obj is GuideFrontmatter {`Invalid guide frontmatter: Title must exist and be a string. Received: ${obj.title}`)}+ if ('subtitle' in obj && typeof obj.subtitle !== 'string') {+ throw Error(`Invalid guide frontmatter: Subtitle must be a sring. Received: ${obj.subtitle}`)+ }if ('description' in obj && typeof obj.description !== 'string') {throw Error(`Invalid guide frontmatter: Description must be a string. Received: ${obj.description}`)}+ if ('canonical' in obj && typeof obj.canonical !== 'string') {+ throw Error(`Invalid guide frontmatter: Canonical must be a string. Received: ${obj.canonical}`)+ }+ if ('hideToc' in obj && typeof obj.hideToc !== 'boolean') {+ throw Error(`Invalid guide frontmatter: hideToc must be a boolean. Received: ${obj.hideToc}`)+ }+ if ('hide_table_of_contents' in obj && typeof obj.hide_table_of_contents !== 'boolean') {+ throw Error(+ `Invalid guide frontmatter: hide_table_of_contents must be a boolean. Received ${obj.hide_table_of_contents}`+ )+ }+ if ('tocVideo' in obj && typeof obj.tocVideo !== 'string') {+ throw Error(`Invalid guide frontmatter: tocVideo must be a string. Received ${obj.tocVideo}`)+ }return true}diff --git a/apps/docs/lib/fetch/feedback.ts b/apps/docs/lib/fetch/feedback.tsindex 670780b7c7c..8bafd80ff59 100644--- a/apps/docs/lib/fetch/feedback.ts+++ b/apps/docs/lib/fetch/feedback.ts@@ -20,7 +20,7 @@ export async function sendFeedback({}: SendFeedbackVariables) {const { data, error } = await post('/platform/feedback/docs', {body: {- page: pathname,+ page: pathname ?? '',isHelpful,title,feedback: message,diff --git a/apps/docs/lib/fetch/fetchWrappers.ts b/apps/docs/lib/fetch/fetchWrappers.tsindex 2e3efd513dd..d9e8b9e54d4 100644--- a/apps/docs/lib/fetch/fetchWrappers.ts+++ b/apps/docs/lib/fetch/fetchWrappers.ts@@ -37,13 +37,7 @@ export async function constructHeaders(}export const get: typeof _get = async (url, init) => {- let headers: Headers = null- try {- headers = await constructHeaders(init?.headers)- } catch (err) {- console.error(err)- return { error: err, response: undefined }- }+ const headers = await constructHeaders(init?.headers)return await _get(url, {...init,@@ -52,13 +46,7 @@ export const get: typeof _get = async (url, init) => {}export const post: typeof _post = async (url, init) => {- let headers: Headers = null- try {- headers = await constructHeaders(init?.headers)- } catch (err) {- console.error(err)- return { error: err, response: undefined }- }+ const headers = await constructHeaders(init?.headers)return await _post(url, {...init,@@ -67,13 +55,7 @@ export const post: typeof _post = async (url, init) => {}export const unauthedAllowedPost: typeof _post = async (url, init) => {- let headers: Headers = null- try {- headers = await constructHeaders(init?.headers, { allowUnauthenticated: true })- } catch (err) {- console.error(err)- return { error: err, response: undefined }- }+ const headers = await constructHeaders(init?.headers, { allowUnauthenticated: true })return await _post(url, {...init,diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjsindex c5b7e34687a..d4aa7eb649e 100644--- a/apps/docs/next.config.mjs+++ b/apps/docs/next.config.mjs@@ -34,6 +34,7 @@ const withMDX = nextMdx({})/** @type {import('next').NextConfig} nextConfig */+const nextConfig = {// Append the default value with md extensionspageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 87c4a3482bf..c53f5267d10 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -98,6 +98,7 @@"ejs": "^3.1.10","globby": "^13.2.2","jest-environment-jsdom": "^29.7.0",+ "nextjs-node-loader": "^1.1.5","npm-run-all": "^4.1.5","openapi-types": "^12.1.3","simple-git": "^3.24.0",diff --git a/apps/docs/pages/__dev-secret-auth.tsx b/apps/docs/pages/__dev-secret-auth.tsxindex de882c374f1..eccae335bda 100644--- a/apps/docs/pages/__dev-secret-auth.tsx+++ b/apps/docs/pages/__dev-secret-auth.tsx@@ -1,4 +1,4 @@-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import { Button_Shadcn_ } from 'ui'import { auth } from '~/lib/userAuth'diff --git a/apps/docs/pages/guides/ai/[[...slug]].tsx b/apps/docs/pages/guides/ai/[[...slug]].tsxdeleted file mode 100644index a19f8a02e54..00000000000--- a/apps/docs/pages/guides/ai/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('ai')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('ai', args)-}) satisfies GetStaticProps--export default function AiGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Ai}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/ai/python/[slug].tsx b/apps/docs/pages/guides/ai/python/[slug].tsxdeleted file mode 100644index 952e4bfa099..00000000000--- a/apps/docs/pages/guides/ai/python/[slug].tsx+++ /dev/null@@ -1,157 +0,0 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'-import { GetStaticPaths, GetStaticProps } from 'next'-import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import { relative } from 'path'-import rehypeSlug from 'rehype-slug'-import remarkGfm from 'remark-gfm'-import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }-import components from '~/components'-import Layout from '~/layouts/DefaultGuideLayout'-import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'-import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'-import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'--// We fetch these docs at build time from an external repo-const org = 'supabase'-const repo = 'vecs'-const branch = 'main'-const docsDir = 'docs'-const externalSite = 'https://supabase.github.io/vecs'--// Each external docs page is mapped to a local page-const pageMap = [- {- slug: 'api',- meta: {- title: 'API',- },- remoteFile: 'api.md',- },- {- slug: 'collections',- meta: {- title: 'Collections',- },- remoteFile: 'concepts_collections.md',- },- {- slug: 'indexes',- meta: {- title: 'Indexes',- },- remoteFile: 'concepts_indexes.md',- },- {- slug: 'metadata',- meta: {- title: 'Metadata',- },- remoteFile: 'concepts_metadata.md',- },-]--interface PythonClientDocsProps {- source: MDXRemoteSerializeResult- meta: {- title: string- description?: string- }-}--export default function PythonClientDocs({ source, meta }: PythonClientDocsProps) {- return (- <Layout meta={meta} menuId={MenuId.Ai}>- <MDXRemote {...source} components={components} />- </Layout>- )-}--/**- * Fetch markdown from external repo and transform links- */-export const getStaticProps: GetStaticProps<PythonClientDocsProps> = async ({ params }) => {- const page = pageMap.find(({ slug }) => slug === params.slug)-- if (!page) {- throw new Error(`No page mapping found for slug '${params.slug}'`)- }-- const { remoteFile, meta } = page-- const response = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`- )-- const source = await response.text()-- const urlTransform: UrlTransformFunction = (url) => {- try {- const externalSiteUrl = new URL(externalSite)-- const placeholderHostname = 'placeholder'- const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)-- // Don't modify a url with a FQDN or a url that's only a hash- if (hostname !== placeholderHostname || pathname === '/') {- return url- }-- const relativePage = (- pathname.endsWith('.md')- ? pathname.replace(/\.md$/, '')- : relative(externalSiteUrl.pathname, pathname)- ).replace(/^\//, '')-- const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)-- // If we have a mapping for this page, use the mapped path- if (page) {- return page.slug + hash- }-- // If we don't have this page in our docs, link to original docs- return `${externalSite}/${relativePage}${hash}`- } catch (err) {- console.error('Error transforming markdown URL', err)- return url- }- }-- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const mdxSource = await serialize(source, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],- },- })-- return { props: { source: mdxSource, meta } }-}--export const getStaticPaths: GetStaticPaths = async () => {- return {- paths: pageMap.map(({ slug }) => ({- params: {- slug,- },- })),- fallback: false,- }-}diff --git a/apps/docs/pages/guides/api/[[...slug]].tsx b/apps/docs/pages/guides/api/[[...slug]].tsxdeleted file mode 100644index 80b2d9f4e80..00000000000--- a/apps/docs/pages/guides/api/[[...slug]].tsx+++ /dev/null@@ -1,30 +0,0 @@-import { stripIndent } from 'common-tags'-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('api')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('api', args)-}) satisfies GetStaticProps--export default function ApiGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Api}>- <MDXRemote {...mdxSource} components={components} scope={{ stripIndent }} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/auth/[[...slug]].tsx b/apps/docs/pages/guides/auth/[[...slug]].tsxdeleted file mode 100644index 9e645a917ea..00000000000--- a/apps/docs/pages/guides/auth/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('auth')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('auth', args)-}) satisfies GetStaticProps--export default function AuthGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Auth}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/cli/[[...slug]].tsx b/apps/docs/pages/guides/cli/[[...slug]].tsxdeleted file mode 100644index 2dd168f672d..00000000000--- a/apps/docs/pages/guides/cli/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('cli')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('cli', args)-}) satisfies GetStaticProps--export default function CliGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Cli}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/cli/github-action/[slug].tsx b/apps/docs/pages/guides/cli/github-action/[slug].tsxdeleted file mode 100644index d06701295e5..00000000000--- a/apps/docs/pages/guides/cli/github-action/[slug].tsx+++ /dev/null@@ -1,159 +0,0 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'-import { GetStaticPaths, GetStaticProps } from 'next'-import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import { relative } from 'path'-import rehypeSlug from 'rehype-slug'-import remarkGfm from 'remark-gfm'-import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }-import components from '~/components'-import Layout from '~/layouts/DefaultGuideLayout'-import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'-import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'-import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'-import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'--// We fetch these docs at build time from an external repo-const org = 'supabase'-const repo = 'setup-cli'-const branch = 'gh-pages'-const docsDir = 'docs'-const externalSite = 'https://supabase.github.io/setup-cli'--// Each external docs page is mapped to a local page-const pageMap = [- {- slug: 'generating-types',- meta: {- title: 'Generate types using GitHub Actions',- description: 'End-to-end type safety across client, server, and database.',- subtitle: 'End-to-end type safety across client, server, and database.',- tocVideo: 'VSNgAIObBdw',- },- remoteFile: 'generating-types.md',- },- {- slug: 'testing',- meta: {- title: 'Automated testing using GitHub Actions',- description: 'Run your tests when you or your team make changes.',- subtitle: 'Run your tests when you or your team make changes.',- },- remoteFile: 'testing.md',- },- {- slug: 'backups',- meta: {- title: 'Automated backups using GitHub Actions',- description: 'Backup your database on a regular basis.',- subtitle: 'Backup your database on a regular basis.',- },- remoteFile: 'backups.md',- },-]--interface ActionDocsProps {- source: MDXRemoteSerializeResult- meta: {- title: string- description?: string- }-}--export default function ActionDocs({ source, meta }: ActionDocsProps) {- return (- <Layout meta={meta} menuId={MenuId.Cli}>- <MDXRemote {...source} components={components} />- </Layout>- )-}--/**- * Fetch markdown from external repo and transform links- */-export const getStaticProps: GetStaticProps<ActionDocsProps> = async ({ params }) => {- const page = pageMap.find(({ slug }) => slug === params.slug)-- if (!page) {- throw new Error(`No page mapping found for slug '${params.slug}'`)- }-- const { remoteFile, meta } = page-- const response = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`- )-- const source = await response.text()-- const urlTransform: UrlTransformFunction = (url) => {- try {- const externalSiteUrl = new URL(externalSite)-- const placeholderHostname = 'placeholder'- const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)-- // Don't modify a url with a FQDN or a url that's only a hash- if (hostname !== placeholderHostname || pathname === '/') {- return url- }-- const relativePage = (- pathname.endsWith('.md')- ? pathname.replace(/\.md$/, '')- : relative(externalSiteUrl.pathname, pathname)- ).replace(/^\//, '')-- const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)-- // If we have a mapping for this page, use the mapped path- if (page) {- return page.slug + hash- }-- // If we don't have this page in our docs, link to original docs- return `${externalSite}/${relativePage}${hash}`- } catch (err) {- console.error('Error transforming markdown URL', err)- return url- }- }-- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const mdxSource = await serialize(source, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- remarkPyMdownTabs,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],- },- })-- return { props: { source: mdxSource, meta } }-}--export const getStaticPaths: GetStaticPaths = async () => {- return {- paths: pageMap.map(({ slug }) => ({- params: {- slug,- },- })),- fallback: false,- }-}diff --git a/apps/docs/pages/guides/database/[[...slug]].tsx b/apps/docs/pages/guides/database/[[...slug]].tsxdeleted file mode 100644index 0ee6416477b..00000000000--- a/apps/docs/pages/guides/database/[[...slug]].tsx+++ /dev/null@@ -1,39 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- const paths = await getGuidesStaticPaths('database')-- /**- * Wrappers is special, so remove it- * Needs to be handled within its own subdirectory or won't build on dev- */- paths.paths = paths.paths.filter(- ({ params }) => !(params.slug.at(0) === 'extensions' && params.slug.at(1) === 'wrappers')- )-- return paths-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('database', args)-}) satisfies GetStaticProps--export default function DatabaseGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Database}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/database/extensions/wrappers/[[...slug]].tsx b/apps/docs/pages/guides/database/extensions/wrappers/[[...slug]].tsxdeleted file mode 100644index 3879c045049..00000000000--- a/apps/docs/pages/guides/database/extensions/wrappers/[[...slug]].tsx+++ /dev/null@@ -1,212 +0,0 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'-import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import { relative } from 'node:path'-import rehypeSlug from 'rehype-slug'-import emoji from 'remark-emoji'-import remarkGfm from 'remark-gfm'--import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'-import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'-import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'-import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'-import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'--// We fetch these docs at build time from an external repo-const org = 'supabase'-const repo = 'wrappers'-const branch = 'main'-const docsDir = 'docs'-const externalSite = 'https://supabase.github.io/wrappers'--// Each external docs page is mapped to a local page-const pageMap = [- {- slug: 'airtable',- meta: {- title: 'Airtable',- },- remoteFile: 'airtable.md',- },- {- slug: 'auth0',- meta: {- title: 'Auth0',- },- remoteFile: 'auth0.md',- },- {- slug: 'bigquery',- meta: {- title: 'BigQuery',- },- remoteFile: 'bigquery.md',- },- {- slug: 'clickhouse',- meta: {- title: 'ClickHouse',- },- remoteFile: 'clickhouse.md',- },- {- slug: 'cognito',- meta: {- title: 'AWS Cognito',- },- remoteFile: 'cognito.md',- },- {- slug: 'firebase',- meta: {- title: 'Firebase',- },- remoteFile: 'firebase.md',- },- {- slug: 'logflare',- meta: {- title: 'Logflare',- },- remoteFile: 'logflare.md',- },- {- slug: 'mssql',- meta: {- title: 'MSSQL',- },- remoteFile: 'mssql.md',- },- {- slug: 'redis',- meta: {- title: 'Redis',- },- remoteFile: 'redis.md',- },- {- slug: 's3',- meta: {- title: 'AWS S3',- },- remoteFile: 's3.md',- },- {- slug: 'stripe',- meta: {- title: 'Stripe',- },- remoteFile: 'stripe.md',- },-]--export default function WrappersDocs({- source,- meta,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- return (- <Layout meta={meta} editLink={editLink} menuId={MenuId.Database}>- <MDXRemote {...source} components={components} />- </Layout>- )-}--/**- * Fetch markdown from external repo and transform links- */-export const getStaticProps: GetStaticProps = async (args) => {- const { params } = args- const federatedPage = pageMap.find(({ slug }) => slug === params.slug.at(0))-- if (!federatedPage) {- const { props } = await getGuidesStaticProps('database/extensions/wrappers', args)- return {- props: {- source: props.mdxSource,- meta: props.frontmatter,- },- }- }-- const { remoteFile, meta } = federatedPage- const repoPath = `${org}/${repo}/${branch}/${docsDir}/${remoteFile}`- const repoEditPath = `${org}/${repo}/blob/${branch}/${docsDir}/${remoteFile}`- const response = await fetch(`https://raw.githubusercontent.com/${repoPath}`)-- const source = await response.text()-- const urlTransform: UrlTransformFunction = (url) => {- try {- const externalSiteUrl = new URL(externalSite)-- const placeholderHostname = 'placeholder'- const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)-- // Don't modify a url with a FQDN or a url that's only a hash- if (hostname !== placeholderHostname || pathname === '/') {- return url- }- const relativePage = (- pathname.endsWith('.md')- ? pathname.replace(/\.md$/, '')- : relative(externalSiteUrl.pathname, pathname)- ).replace(/^\//, '')-- const page = pageMap.find(({ remoteFile }) => `${relativePage}.md` === remoteFile)-- // If we have a mapping for this page, use the mapped path- if (page) {- return page.slug + hash- }-- // If we don't have this page in our docs, link to original docs- return `${externalSite}/${relativePage}${hash}`- } catch (err) {- console.error('Error transforming markdown URL', err)- return url- }- }-- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const mdxSource = await serialize(source, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- emoji,- remarkPyMdownTabs,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],- },- })-- return { props: { source: mdxSource, meta, editLink: repoEditPath } }-}--export const getStaticPaths: GetStaticPaths = async () => {- const mdxPaths = (await getGuidesStaticPaths('database/extensions/wrappers')).paths- const federatedPaths = pageMap.map(({ slug }) => ({ params: { slug: [slug] } }))- return {- paths: [...federatedPaths, ...mdxPaths],- fallback: false,- }-}diff --git a/apps/docs/pages/guides/functions/[[...slug]].tsx b/apps/docs/pages/guides/functions/[[...slug]].tsxdeleted file mode 100644index 8a8ed0defd2..00000000000--- a/apps/docs/pages/guides/functions/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('functions')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('functions', args)-}) satisfies GetStaticProps--export default function FunctionsGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Functions}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/getting-started/[[...slug]].tsx b/apps/docs/pages/guides/getting-started/[[...slug]].tsxdeleted file mode 100644index e16c15ac68f..00000000000--- a/apps/docs/pages/guides/getting-started/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('getting-started')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('getting-started', args)-}) satisfies GetStaticProps--export default function GettingStartedGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.GettingStarted}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/graphql/[[...slug]].tsx b/apps/docs/pages/guides/graphql/[[...slug]].tsxdeleted file mode 100644index 00eaecfe221..00000000000--- a/apps/docs/pages/guides/graphql/[[...slug]].tsx+++ /dev/null@@ -1,220 +0,0 @@-import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'-import { GetStaticPaths, GetStaticProps } from 'next'-import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'-import { isAbsolute, relative } from 'path'-import rehypeSlug from 'rehype-slug'-import remarkGfm from 'remark-gfm'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { UrlTransformFunction, linkTransform } from '~/lib/mdx/plugins/rehypeLinkTransform'-import remarkMkDocsAdmonition from '~/lib/mdx/plugins/remarkAdmonition'-import { removeTitle } from '~/lib/mdx/plugins/remarkRemoveTitle'-import remarkPyMdownTabs from '~/lib/mdx/plugins/remarkTabs'--import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }--// We fetch these docs at build time from an external repo-const org = 'supabase'-const repo = 'pg_graphql'-const branch = 'master'-const docsDir = 'docs'-const externalSite = 'https://supabase.github.io/pg_graphql'--// Each external docs page is mapped to a local page-const pageMap = [- {- meta: {- id: 'graphql-overview',- title: 'GraphQL',- subtitle: 'Autogenerated GraphQL APIs with Postgres.',- },- remoteFile: 'supabase.md',- },- {- slug: 'api',- meta: {- id: 'graphql-api',- title: 'GraphQL API',- subtitle: 'Understanding the core concepts of the GraphQL API.',- },- remoteFile: 'api.md',- },- {- slug: 'views',- meta: {- id: 'graphql-views',- title: 'Views',- subtitle: 'Using Postgres Views with GraphQL.',- },- remoteFile: 'views.md',- },- {- slug: 'functions',- meta: {- id: 'graphql-functions',- title: 'Functions',- subtitle: 'Using Postgres Functions with GraphQL.',- },- remoteFile: 'functions.md',- },- {- slug: 'computed-fields',- meta: {- id: 'graphql-computed-fields',- title: 'Computed Fields',- subtitle: 'Using Postgres Computed Fields with GraphQL.',- },- remoteFile: 'computed-fields.md',- },- {- slug: 'configuration',- meta: {- id: 'graphql-configuration',- title: 'Configuration & Customization',- subtitle: 'Extra configuration options can be set on SQL entities using comment directives.',- },- remoteFile: 'configuration.md',- },- {- slug: 'security',- meta: {- id: 'graphql-security',- title: 'Security',- subtitle: 'Securing your GraphQL API.',- },- remoteFile: 'security.md',- },- {- slug: 'with-apollo',- meta: {- id: 'graphql-with-apollo',- title: 'With Apollo',- subtitle: 'Using pg_grapqhl with Apollo.',- },- remoteFile: 'usage_with_apollo.md',- },- {- slug: 'with-relay',- meta: {- id: 'graphql-with-relay',- title: 'With Relay',- subtitle: 'Using pg_grapqhl with Relay.',- },- remoteFile: 'usage_with_relay.md',- },-]--interface PGGraphQLDocsProps {- source: MDXRemoteSerializeResult- meta: {- title: string- description?: string- }-}--export default function PGGraphQLDocs({ source, meta }: PGGraphQLDocsProps) {- return (- <Layout meta={meta} menuId={MenuId.Graphql}>- <MDXRemote {...source} components={components} />- </Layout>- )-}--/**- * Fetch markdown from external repo and transform links- */-export const getStaticProps: GetStaticProps<PGGraphQLDocsProps> = async ({ params }) => {- const [slug] = params.slug ?? []- const page = pageMap.find((page) => page.slug === slug)-- if (!page) {- throw new Error(`No page mapping found for slug '${slug}'`)- }-- const { remoteFile, meta } = page-- const response = await fetch(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${docsDir}/${remoteFile}`- )-- const source = await response.text()-- const urlTransform: UrlTransformFunction = (url) => {- try {- const externalSiteUrl = new URL(externalSite)-- const placeholderHostname = 'placeholder'- const { hostname, pathname, hash } = new URL(url, `http://${placeholderHostname}`)-- // Don't modify a url with a FQDN or a url that's only a hash- if (hostname !== placeholderHostname || pathname === '/') {- return url- }-- const getRelativePath = () => {- if (pathname.endsWith('.md')) {- return pathname.replace(/\.md$/, '')- }- if (isAbsolute(url)) {- return relative(externalSiteUrl.pathname, pathname)- }- return pathname- }-- const relativePath = getRelativePath().replace(/^\//, '')-- const page = pageMap.find(({ remoteFile }) => `${relativePath}.md` === remoteFile)-- // If we have a mapping for this page, use the mapped path- if (page) {- return 'graphql/' + page.slug + hash- }-- // If we don't have this page in our docs, link to original docs- return `${externalSite}/${relativePath}${hash}`- } catch (err) {- console.error('Error transforming markdown URL', err)- return url- }- }-- const codeHikeOptions: CodeHikeConfig = {- theme: codeHikeTheme,- lineNumbers: true,- showCopyButton: true,- skipLanguages: [],- autoImport: false,- }-- const mdxSource = await serialize(source, {- scope: {- chCodeConfig: codeHikeOptions,- },- mdxOptions: {- remarkPlugins: [- remarkGfm,- remarkMkDocsAdmonition,- remarkPyMdownTabs,- [removeTitle, meta.title],- [remarkCodeHike, codeHikeOptions],- ],- rehypePlugins: [[linkTransform, urlTransform], rehypeSlug],- },- })-- return { props: { source: mdxSource, meta } }-}--export const getStaticPaths: GetStaticPaths = async () => {- return {- paths: pageMap.map(({ slug }) => ({- params: {- slug: slug ? [slug] : [],- },- })),- fallback: false,- }-}diff --git a/apps/docs/pages/guides/platform/[[...slug]].tsx b/apps/docs/pages/guides/platform/[[...slug]].tsxdeleted file mode 100644index f20307d7974..00000000000--- a/apps/docs/pages/guides/platform/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('platform')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('platform', args)-}) satisfies GetStaticProps--export default function PlatformGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Platform}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/realtime/[[...slug]].tsx b/apps/docs/pages/guides/realtime/[[...slug]].tsxdeleted file mode 100644index 3a90134f5ad..00000000000--- a/apps/docs/pages/guides/realtime/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('realtime')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('realtime', args)-}) satisfies GetStaticProps--export default function RealtimeGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Realtime}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/resources/[[...slug]].tsx b/apps/docs/pages/guides/resources/[[...slug]].tsxdeleted file mode 100644index d73ad930fe5..00000000000--- a/apps/docs/pages/guides/resources/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('resources')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('resources', args)-}) satisfies GetStaticProps--export default function ResourcesGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Resources}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/self-hosting/[[...slug]].tsx b/apps/docs/pages/guides/self-hosting/[[...slug]].tsxdeleted file mode 100644index c63d1c13b75..00000000000--- a/apps/docs/pages/guides/self-hosting/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('self-hosting')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('self-hosting', args)-}) satisfies GetStaticProps--export default function SelfHostingGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.SelfHosting}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/guides/self-hosting/analytics/config.tsx b/apps/docs/pages/guides/self-hosting/analytics/config.tsxdeleted file mode 100644index 3946fc2c55c..00000000000--- a/apps/docs/pages/guides/self-hosting/analytics/config.tsx+++ /dev/null@@ -1,67 +0,0 @@-import { type InferGetStaticPropsType, type GetStaticProps } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Param from '~/components/Params'-import Layout from '~/layouts/DefaultGuideLayout'-import { getAnalyticsConfigV0 } from '~/lib/mdx/getConfig'--const meta = {- title: 'Analytics Self-hosting Config',- description: 'How to configure and deploy Supabase Analytics.',-}--export const getStaticProps = (async () => {- const spec = getAnalyticsConfigV0()- const descriptionSource = await serialize(spec.info.description)- return {- props: {- descriptionSource,- spec,- },- }-}) satisfies GetStaticProps--export const Page = (props: InferGetStaticPropsType<typeof getStaticProps>) => (- <Layout- meta={meta}- editLink="/supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/analytics/config.tsx"- menuId={MenuId.SelfHosting}- >- <MDXRemote {...props.descriptionSource} components={components} />-- <div>- {props.spec.info.tags.map((tag: ReturnType<typeof getAnalyticsConfigV0>['info']['tags']) => {- return (- <>- <h2 className="text-foreground">{tag.title}</h2>- <p className="text-foreground-lighter">{tag.description}</p>- <div className="not-prose">- <h5 className="text-base text-foreground mb-3">Parameters</h5>- <ul>- {props.spec.parameters- .filter((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) =>- param.tags.includes(tag.id)- )- .map((param: ReturnType<typeof getAnalyticsConfigV0>['parameters']) => {- return (- <Param- name={param.title}- type={param.type}- description={param.description}- required={param.required}- />- )- })}- </ul>- </div>- </>- )- })}- </div>- </Layout>-)--export default Pagediff --git a/apps/docs/pages/guides/self-hosting/auth/config.tsx b/apps/docs/pages/guides/self-hosting/auth/config.tsxdeleted file mode 100644index 5702f8a5379..00000000000--- a/apps/docs/pages/guides/self-hosting/auth/config.tsx+++ /dev/null@@ -1,67 +0,0 @@-import { type InferGetStaticPropsType, type GetStaticProps } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Param from '~/components/Params'-import Layout from '~/layouts/DefaultGuideLayout'-import { getAuthConfigV1 } from '~/lib/mdx/getConfig'--const meta = {- title: 'Auth Self-hosting Config',- description: 'How to configure and deploy Supabase Auth.',-}--export const getStaticProps = (async () => {- const spec = getAuthConfigV1()- const descriptionSource = await serialize(spec.info.description)- return {- props: {- descriptionSource,- spec,- },- }-}) satisfies GetStaticProps--export const Page = (props: InferGetStaticPropsType<typeof getStaticProps>) => (- <Layout- meta={meta}- editLink="/supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/analytics/config.tsx"- menuId={MenuId.SelfHosting}- >- <MDXRemote {...props.descriptionSource} components={components} />-- <div>- {props.spec.info.tags.map((tag: ReturnType<typeof getAuthConfigV1>['info']['tags']) => {- return (- <>- <h2 className="text-foreground">{tag.title}</h2>- <p className="text-foreground-lighter">{tag.description}</p>- <div className="not-prose">- <h5 className="text-base text-foreground mb-3">Parameters</h5>- <ul>- {props.spec.parameters- .filter((param: ReturnType<typeof getAuthConfigV1>['parameters']) =>- param.tags.includes(tag.id)- )- .map((param: ReturnType<typeof getAuthConfigV1>['parameters']) => {- return (- <Param- name={param.title}- type={param.type}- description={param.description}- required={param.required}- />- )- })}- </ul>- </div>- </>- )- })}- </div>- </Layout>-)--export default Pagediff --git a/apps/docs/pages/guides/self-hosting/realtime/config.tsx b/apps/docs/pages/guides/self-hosting/realtime/config.tsxdeleted file mode 100644index 09df809537c..00000000000--- a/apps/docs/pages/guides/self-hosting/realtime/config.tsx+++ /dev/null@@ -1,67 +0,0 @@-import { type InferGetStaticPropsType, type GetStaticProps } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Param from '~/components/Params'-import Layout from '~/layouts/DefaultGuideLayout'-import { getRealtimeConfigV0 } from '~/lib/mdx/getConfig'--const meta = {- title: 'Realtime Self-hosting Config',- description: 'How to configure and deploy Supabase Realtime.',-}--export const getStaticProps = (async () => {- const spec = getRealtimeConfigV0()- const descriptionSource = await serialize(spec.info.description)- return {- props: {- descriptionSource,- spec,- },- }-}) satisfies GetStaticProps--export const Page = (props: InferGetStaticPropsType<typeof getStaticProps>) => (- <Layout- meta={meta}- editLink="/supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/analytics/config.tsx"- menuId={MenuId.SelfHosting}- >- <MDXRemote {...props.descriptionSource} components={components} />-- <div>- {props.spec.info.tags.map((tag: ReturnType<typeof getRealtimeConfigV0>['info']['tags']) => {- return (- <>- <h2 className="text-foreground">{tag.title}</h2>- <p className="text-foreground-lighter">{tag.description}</p>- <div className="not-prose">- <h5 className="text-base text-foreground mb-3">Parameters</h5>- <ul>- {props.spec.parameters- .filter((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) =>- param.tags.includes(tag.id)- )- .map((param: ReturnType<typeof getRealtimeConfigV0>['parameters']) => {- return (- <Param- name={param.title}- type={param.type}- description={param.description}- required={param.required}- />- )- })}- </ul>- </div>- </>- )- })}- </div>- </Layout>-)--export default Pagediff --git a/apps/docs/pages/guides/self-hosting/storage/config.tsx b/apps/docs/pages/guides/self-hosting/storage/config.tsxdeleted file mode 100644index 8a131f674ac..00000000000--- a/apps/docs/pages/guides/self-hosting/storage/config.tsx+++ /dev/null@@ -1,67 +0,0 @@-import { type InferGetStaticPropsType, type GetStaticProps } from 'next'-import { MDXRemote } from 'next-mdx-remote'-import { serialize } from 'next-mdx-remote/serialize'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Param from '~/components/Params'-import Layout from '~/layouts/DefaultGuideLayout'-import { getStorageConfigV0 } from '~/lib/mdx/getConfig'--const meta = {- title: 'Storage Self-hosting Config',- description: 'How to configure and deploy Supabase Storage.',-}--export const getStaticProps = (async () => {- const spec = getStorageConfigV0()- const descriptionSource = await serialize(spec.info.description)- return {- props: {- descriptionSource,- spec,- },- }-}) satisfies GetStaticProps--export const Page = (props: InferGetStaticPropsType<typeof getStaticProps>) => (- <Layout- meta={meta}- editLink="/supabase/supabase/blob/master/apps/docs/pages/guides/self-hosting/analytics/config.tsx"- menuId={MenuId.SelfHosting}- >- <MDXRemote {...props.descriptionSource} components={components} />-- <div>- {props.spec.info.tags.map((tag: ReturnType<typeof getStorageConfigV0>['info']['tags']) => {- return (- <>- <h2 className="text-foreground">{tag.title}</h2>- <p className="text-foreground-lighter">{tag.description}</p>- <div className="not-prose">- <h5 className="text-base text-foreground mb-3">Parameters</h5>- <ul>- {props.spec.parameters- .filter((param: ReturnType<typeof getStorageConfigV0>['parameters']) =>- param.tags.includes(tag.id)- )- .map((param: ReturnType<typeof getStorageConfigV0>['parameters']) => {- return (- <Param- name={param.title}- type={param.type}- description={param.description}- required={param.required}- />- )- })}- </ul>- </div>- </>- )- })}- </div>- </Layout>-)--export default Pagediff --git a/apps/docs/pages/guides/storage/[[...slug]].tsx b/apps/docs/pages/guides/storage/[[...slug]].tsxdeleted file mode 100644index 90c4b978d88..00000000000--- a/apps/docs/pages/guides/storage/[[...slug]].tsx+++ /dev/null@@ -1,29 +0,0 @@-import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'-import { MDXRemote } from 'next-mdx-remote'--import components from '~/components'-import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'-import Layout from '~/layouts/DefaultGuideLayout'-import { getGuidesStaticPaths, getGuidesStaticProps } from '~/lib/docs'--export const getStaticPaths = (async () => {- return getGuidesStaticPaths('storage')-}) satisfies GetStaticPaths--export const getStaticProps = (async (args) => {- return getGuidesStaticProps('storage', args)-}) satisfies GetStaticProps--export default function StorageGuide({- frontmatter,- mdxSource,- editLink,-}: InferGetStaticPropsType<typeof getStaticProps>) {- const { hideToc, ...meta } = frontmatter-- return (- <Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Storage}>- <MDXRemote {...mdxSource} components={components} />- </Layout>- )-}diff --git a/apps/docs/pages/reference/csharp/crawlers/[...slug].tsx b/apps/docs/pages/reference/csharp/crawlers/[...slug].tsxindex d16769cb83a..fb85f51b023 100644--- a/apps/docs/pages/reference/csharp/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/csharp/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'import type { TypeSpec } from '~/components/reference/Reference.types'diff --git a/apps/docs/pages/reference/csharp/v0/crawlers/[...slug].tsx b/apps/docs/pages/reference/csharp/v0/crawlers/[...slug].tsxindex 101c289bddb..b5b5f35127a 100644--- a/apps/docs/pages/reference/csharp/v0/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/csharp/v0/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/dart/crawlers/[...slug].tsx b/apps/docs/pages/reference/dart/crawlers/[...slug].tsxindex b18c2eeff9b..0ea7d9bcaed 100644--- a/apps/docs/pages/reference/dart/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/dart/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/dart/v1/crawlers/[...slug].tsx b/apps/docs/pages/reference/dart/v1/crawlers/[...slug].tsxindex 1843e626e5f..7945563e867 100644--- a/apps/docs/pages/reference/dart/v1/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/dart/v1/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/index.mdx b/apps/docs/pages/reference/index.mdxdeleted file mode 100644index f6eeec0d70a..00000000000--- a/apps/docs/pages/reference/index.mdx+++ /dev/null@@ -1,79 +0,0 @@-import Layout from '~/layouts/DefaultGuideLayout'--export const meta = {- id: 'reference',- title: 'Reference Documentation',- sidebar_label: 'Reference Documentation',- hide_table_of_contents: true,-}--Reference documentation for the official Supabase client libraries, APIs, and tools.--<div className="container p-0 not-prose">- <div className="grid grid-cols-2 gap-3">- <div>- <ButtonCard- icon="/docs/img/icons/javascript-icon.svg"- to="/reference/javascript"- title="JavaScript"- description="JavaScript and TypeScript documentation."- />- </div>- <div>- <ButtonCard- icon="/docs/img/icons/flutter-icon.svg"- to="/reference/dart"- title="Flutter"- description="Flutter and Dart documentation."- />- </div>- <div>- <ButtonCard icon="/docs/img/icons/cli-icon.svg"- to="/reference/cli"- title="Supabase CLI"- description="Tools for developing your Supabase projects locally."- />- </div>- <div>- <ButtonCard icon="/docs/img/icons/api-icon.svg"- to="/reference/api"- title="Management API"- description="Manage your Supabase projects programmatically." />- </div>-- </div>-</div>--## Self-hosting--Reference documentation for self-hosting Supabase features.--<div className="container">- <div className="grid grid-cols-2 gap-3 not-prose">- <div className="w-1/2">- <ButtonCard- to="/reference/auth"- title="Auth Server"- description=" JSON Web Token (JWT)-based API for managing users and issuing access tokens."- />- </div>- <div>- <ButtonCard- to="/reference/realtime"- title="Realtime"- description="Build multiplayer applications and listen to your database changes via websockets."- />- </div>- <div>- <ButtonCard- to="/reference/storage"- title="Storage"- description="S3-compatible object storage service that integrates with Postgres."- />- </div>- </div>-</div>--export const Page = ({ children }) => <Layout meta={meta} children={children} />--export default Pagediff --git a/apps/docs/pages/reference/javascript/crawlers/[...slug].tsx b/apps/docs/pages/reference/javascript/crawlers/[...slug].tsxindex a307a3eac07..b213488f963 100644--- a/apps/docs/pages/reference/javascript/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/javascript/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/javascript/v1/crawlers/[...slug].tsx b/apps/docs/pages/reference/javascript/v1/crawlers/[...slug].tsxindex 09cd60e404c..d4647642a7f 100644--- a/apps/docs/pages/reference/javascript/v1/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/javascript/v1/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/kotlin/crawlers/[...slug].tsx b/apps/docs/pages/reference/kotlin/crawlers/[...slug].tsxindex 2f3885d524b..ec9ba3975f7 100644--- a/apps/docs/pages/reference/kotlin/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/kotlin/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/kotlin/v1/crawlers/[...slug].tsx b/apps/docs/pages/reference/kotlin/v1/crawlers/[...slug].tsxindex 7a5ada7a194..eccaa115e21 100644--- a/apps/docs/pages/reference/kotlin/v1/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/kotlin/v1/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/python/crawlers/[...slug].tsx b/apps/docs/pages/reference/python/crawlers/[...slug].tsxindex bb549d62305..8534a8767ae 100644--- a/apps/docs/pages/reference/python/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/python/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/swift/crawlers/[...slug].tsx b/apps/docs/pages/reference/swift/crawlers/[...slug].tsxindex 69000ea9674..9763d9c668b 100644--- a/apps/docs/pages/reference/swift/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/swift/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/pages/reference/swift/v1/crawlers/[...slug].tsx b/apps/docs/pages/reference/swift/v1/crawlers/[...slug].tsxindex 1ef50177ac2..0156927cbe0 100644--- a/apps/docs/pages/reference/swift/v1/crawlers/[...slug].tsx+++ b/apps/docs/pages/reference/swift/v1/crawlers/[...slug].tsx@@ -5,7 +5,7 @@ import RefSectionHandler from '~/components/reference/RefSectionHandler'import { flattenSections } from '~/lib/helpers'import handleRefGetStaticPaths from '~/lib/mdx/handleRefStaticPaths'import handleRefStaticProps from '~/lib/mdx/handleRefStaticProps'-import { useRouter } from 'next/router'+import { useRouter } from 'next/compat/router'import RefSEO from '~/components/reference/RefSEO'import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'diff --git a/apps/docs/spec/supabase_dart_v2.yml b/apps/docs/spec/supabase_dart_v2.ymlindex daf09e3e796..64b53f2499b 100644--- a/apps/docs/spec/supabase_dart_v2.yml+++ b/apps/docs/spec/supabase_dart_v2.yml@@ -600,12 +600,9 @@ functions:import 'package:google_sign_in/google_sign_in.dart';import 'package:supabase_flutter/supabase_flutter.dart';- /// Web Client ID that you registered with Google Cloud.- /// This will be used to perform Google sign in on Android.- const webClientId = 'my-web.apps.googleusercontent.com';+ const webClientId = '<web client ID that you registered on Google Cloud, for example my-web.apps.googleusercontent.com>';- /// iOS Client ID that you registered with Google Cloud.- const iosClientId = 'my-ios.apps.googleusercontent.com';+ const iosClientId = '<iOS client ID that you registered on Google Cloud, for example my-ios.apps.googleusercontent.com';final GoogleSignIn googleSignIn = GoogleSignIn(clientId: iosClientId,diff --git a/package-lock.json b/package-lock.jsonindex efa696b5485..566d55b6310 100644--- a/package-lock.json+++ b/package-lock.json@@ -1006,6 +1006,7 @@"ejs": "^3.1.10","globby": "^13.2.2","jest-environment-jsdom": "^29.7.0",+ "nextjs-node-loader": "^1.1.5","npm-run-all": "^4.1.5","openapi-types": "^12.1.3","simple-git": "^3.24.0",diff --git a/packages/common/Providers.tsx b/packages/common/Providers.tsxindex 123c17134fc..a3f7e8aa062 100644--- a/packages/common/Providers.tsx+++ b/packages/common/Providers.tsx@@ -1,3 +1,5 @@+'use client'+import { ThemeProvider as NextThemesProvider } from 'next-themes'import type { ThemeProviderProps } from 'next-themes/dist/types'diff --git a/packages/common/index.tsx b/packages/common/index.tsxindex e86ffed6d47..a74063ca7a5 100644--- a/packages/common/index.tsx+++ b/packages/common/index.tsx@@ -1,3 +1,5 @@+'use client'+export * from './auth'export * from './constants'export * from './database-types'diff --git a/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx b/packages/ui-patterns/Cmdk/SearchOnlyItem.tsxindex 948d65d6df3..6849487829e 100644--- a/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx+++ b/packages/ui-patterns/Cmdk/SearchOnlyItem.tsx@@ -1,5 +1,5 @@import { CommandItem } from './Command.utils'-import { useRouter } from 'next/router'+import { useRouter } from 'next/navigation'import { useCommandMenu } from './CommandMenuProvider'interface SearchOnlyItemProps {diff --git a/packages/ui-patterns/Cmdk/index.tsx b/packages/ui-patterns/Cmdk/index.tsxindex bb5a6bdc69b..8355b71c86d 100644--- a/packages/ui-patterns/Cmdk/index.tsx+++ b/packages/ui-patterns/Cmdk/index.tsx@@ -2,15 +2,11 @@ export { default as CommandMenuProvider } from './CommandMenuProvider'export * from './CommandMenuProvider'export { default as CommandMenu } from './CommandMenu'-export * from './CommandMenu'export { default as AiCommand } from './AiCommand'-export * from './AiCommand'export { default as DocsSearch } from './DocsSearch'-export * from './DocsSearch'export { default as SearchButton } from './SearchButton'-export * from './SearchButton'export * from './Command.icons'diff --git a/packages/ui/src/components/Checkbox/CheckboxContext.tsx b/packages/ui/src/components/Checkbox/CheckboxContext.tsxindex 742c51f9575..a2a783b01f9 100644--- a/packages/ui/src/components/Checkbox/CheckboxContext.tsx+++ b/packages/ui/src/components/Checkbox/CheckboxContext.tsx@@ -1,3 +1,5 @@+'use client'+import { createContext } from 'react'// Make sure the shape of the default value passed todiff --git a/packages/ui/src/components/ContextMenu/ContextMenu.tsx b/packages/ui/src/components/ContextMenu/ContextMenu.tsxindex b80dcf212fc..a408e14f0a2 100644--- a/packages/ui/src/components/ContextMenu/ContextMenu.tsx+++ b/packages/ui/src/components/ContextMenu/ContextMenu.tsx@@ -1,3 +1,5 @@+'use client'+import React, { useState } from 'react'import { IconCheck } from '../Icon/icons/IconCheck'diff --git a/packages/ui/src/components/Form/FormContext.tsx b/packages/ui/src/components/Form/FormContext.tsxindex 108b23b8cb0..3049bd3a598 100644--- a/packages/ui/src/components/Form/FormContext.tsx+++ b/packages/ui/src/components/Form/FormContext.tsx@@ -1,3 +1,5 @@+'use client'+import React, { createContext, useContext } from 'react'interface ContextProps {diff --git a/packages/ui/src/components/Icon/IconBackground.tsx b/packages/ui/src/components/Icon/IconBackground.tsxindex b48532cc17a..498b73138a4 100644--- a/packages/ui/src/components/Icon/IconBackground.tsx+++ b/packages/ui/src/components/Icon/IconBackground.tsx@@ -1,3 +1,5 @@+'use client'+export const IconBackground: React.FC<React.PropsWithChildren> = (props) => (<div className="shrink-0 bg-brand-200 dark:bg-brand-400 border border-brand-300 dark:border-brand-400 w-8 h-8 flex items-center justify-center rounded">{props.children}diff --git a/packages/ui/src/components/Menu/MenuContext.tsx b/packages/ui/src/components/Menu/MenuContext.tsxindex 3e8b71ab3d8..6264a543708 100644--- a/packages/ui/src/components/Menu/MenuContext.tsx+++ b/packages/ui/src/components/Menu/MenuContext.tsx@@ -1,3 +1,5 @@+'use client'+import React, { createContext, useContext } from 'react'interface ContextProps {@@ -21,9 +23,7 @@ export const MenuContextProvider = (props: Provider) => {type: type,}- return (- <MenuContext.Provider value={value}>{props.children}</MenuContext.Provider>- )+ return <MenuContext.Provider value={value}>{props.children}</MenuContext.Provider>}// context helper to avoid using a consumer componentdiff --git a/packages/ui/src/components/Tabs/TabsProvider.tsx b/packages/ui/src/components/Tabs/TabsProvider.tsxnew file mode 100644index 00000000000..0f0f99470a0--- /dev/null+++ b/packages/ui/src/components/Tabs/TabsProvider.tsx@@ -0,0 +1,105 @@+'use client'++import { xor } from 'lodash'+import {+ type Dispatch,+ type PropsWithChildren,+ type SetStateAction,+ createContext,+ useCallback,+ useContext,+ useMemo,+ useState,+} from 'react'++export interface TabGroup {+ tabIds: string[]+ activeId: string+}++interface TabsContextValue {+ tabGroups: TabGroup[]+ setTabGroups: Dispatch<SetStateAction<TabGroup[]>>+}++const TabsContext = createContext<TabsContextValue>({+ tabGroups: [],+ setTabGroups: () => {},+})++/**+ * Tracks active Tab IDs across the site so that tabs+ * with the same ID stay in sync (eg. JS vs TS tabs).+ */+const TabsProvider = ({ children }: PropsWithChildren<{}>) => {+ const [tabGroups, setTabGroups] = useState<TabGroup[]>([])++ return <TabsContext.Provider value={{ tabGroups, setTabGroups }}>{children}</TabsContext.Provider>+}++export interface UseTabGroupValue {+ /**+ * The active tab ID for the tab group.+ * This value is shared with all matching tab+ * groups within the context.+ */+ groupActiveId?: string++ /**+ * Set the active tab ID for the tab group.+ * Value will be shared with all matching tab+ * groups within the context.+ */+ setGroupActiveId?(id: string): void+}++/**+ * Hook to retrieve and set the active tab ID for+ * the current tab group.+ * The value will be shared with all matching tab+ * groups within the context.+ *+ * Silently fails if no `TabsProvider` is set.+ */+export const useTabGroup = (tabIds: string[]): UseTabGroupValue => {+ const tabsContext = useContext(TabsContext)++ if (!tabsContext) {+ return {}+ }++ const { tabGroups, setTabGroups } = tabsContext++ const groupActiveId = useMemo(+ () => tabGroups.find((group) => xor(group.tabIds, tabIds).length === 0)?.activeId,+ [tabGroups]+ )++ const setGroupActiveId = useCallback((id: string) => {+ setTabGroups((groups) => {+ // Clone the array+ const newGroups = groups.concat()++ const existingGroupIndex = groups.findIndex((group) => xor(group.tabIds, tabIds).length === 0)++ const tabGroup: TabGroup = {+ tabIds,+ activeId: id,+ }++ // If this group already exists, replace it+ // Otherwise add to the end+ if (existingGroupIndex !== -1) {+ newGroups.splice(existingGroupIndex, 1, tabGroup)+ } else {+ newGroups.push(tabGroup)+ }++ return newGroups+ })+ }, [])++ return { groupActiveId, setGroupActiveId }+}++export default TabsProviderdiff --git a/packages/ui/src/components/Toast/Toast.tsx b/packages/ui/src/components/Toast/Toast.tsxindex bb63bfa1150..5d378fccb87 100644--- a/packages/ui/src/components/Toast/Toast.tsx+++ b/packages/ui/src/components/Toast/Toast.tsx@@ -1,3 +1,5 @@+'use client'+import * as Portal from '@radix-ui/react-portal'import React, { ComponentProps } from 'react'import {diff --git a/packages/ui/src/components/shadcn/ui/button.tsx b/packages/ui/src/components/shadcn/ui/button.tsxindex 16b7902ed9c..81e745911eb 100644--- a/packages/ui/src/components/shadcn/ui/button.tsx+++ b/packages/ui/src/components/shadcn/ui/button.tsx@@ -1,3 +1,5 @@+'use client'+import { Slot } from '@radix-ui/react-slot'import { cva, type VariantProps } from 'class-variance-authority'import * as React from 'react'diff --git a/packages/ui/src/components/shadcn/ui/label.tsx b/packages/ui/src/components/shadcn/ui/label.tsxindex 09c5bb63b87..01501620c2f 100644--- a/packages/ui/src/components/shadcn/ui/label.tsx+++ b/packages/ui/src/components/shadcn/ui/label.tsx@@ -1,3 +1,5 @@+'use client'+import * as LabelPrimitive from '@radix-ui/react-label'import { cva, type VariantProps } from 'class-variance-authority'import * as React from 'react'diff --git a/packages/ui/src/components/shadcn/ui/navigation-menu.tsx b/packages/ui/src/components/shadcn/ui/navigation-menu.tsxindex 95cc153e35d..7b21d3ecb69 100644--- a/packages/ui/src/components/shadcn/ui/navigation-menu.tsx+++ b/packages/ui/src/components/shadcn/ui/navigation-menu.tsx@@ -1,3 +1,5 @@+'use client'+import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu'import { cva } from 'class-variance-authority'import { ChevronDown } from 'lucide-react'diff --git a/packages/ui/src/layout/PortalToast/PortalToast.tsx b/packages/ui/src/layout/PortalToast/PortalToast.tsxindex d2ba31cdb06..e4564621ae5 100644--- a/packages/ui/src/layout/PortalToast/PortalToast.tsx+++ b/packages/ui/src/layout/PortalToast/PortalToast.tsx@@ -3,7 +3,7 @@import { X } from 'lucide-react'import dynamic from 'next/dynamic'import { Toaster, ToastBar, toast } from 'react-hot-toast'-import { Button, IconX } from 'ui'+import { Button } from 'ui'const PortalRootWithNoSSR = dynamic(// @ts-ignorediff --git a/packages/ui/src/layout/banners/Announcement.tsx b/packages/ui/src/layout/banners/Announcement.tsxindex b0752c5ae48..a043105509e 100644--- a/packages/ui/src/layout/banners/Announcement.tsx+++ b/packages/ui/src/layout/banners/Announcement.tsx@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'import _announcement from './data/Announcement.json'import { IconX, cn } from 'ui'-import { useRouter } from 'next/router'+import { usePathname } from 'next/navigation'import { PropsWithChildren } from 'react'export interface AnnouncementProps {@@ -31,8 +31,8 @@ const Announcement = ({}: PropsWithChildren<AnnouncementComponentProps>) => {const [hidden, setHidden] = useState(false)- const router = useRouter()- const isLaunchWeekSection = router.pathname.includes('launch-week')+ const pathname = usePathname()+ const isLaunchWeekSection = pathname.includes('launch-week')// override to hide announcementif (!show || !announcement.show) return nulldiff --git a/packages/ui/src/layout/banners/LW11CountdownBanner/LW11CountdownBanner.tsx b/packages/ui/src/layout/banners/LW11CountdownBanner/LW11CountdownBanner.tsxindex eebd3520da7..b92aedbcced 100644--- a/packages/ui/src/layout/banners/LW11CountdownBanner/LW11CountdownBanner.tsx+++ b/packages/ui/src/layout/banners/LW11CountdownBanner/LW11CountdownBanner.tsx@@ -1,16 +1,15 @@'use client'-import { useRouter } from 'next/router'+import { usePathname } from 'next/navigation'import { Button, cn } from 'ui'import announcement from '../data/Announcement.json'import Link from 'next/link'export function LW11CountdownBanner() {- const router = useRouter()- const isHomePage = router.pathname === '/'- const isLaunchWeekPage = router.pathname === '/ga-week'- const isLaunchWeekSection =- router.pathname.includes('/launch-week') || router.pathname.includes('/ga-week')+ const pathname = usePathname()+ const isHomePage = pathname === '/'+ const isLaunchWeekPage = pathname === '/ga-week'+ const isLaunchWeekSection = pathname.includes('/launch-week') || pathname.includes('/ga-week')if (isLaunchWeekPage || isHomePage) return nulldiff --git a/packages/ui/src/lib/Layout/FormLayout/FormLayout.tsx b/packages/ui/src/lib/Layout/FormLayout/FormLayout.tsxindex 1895ed2ac27..6240611f739 100644--- a/packages/ui/src/lib/Layout/FormLayout/FormLayout.tsx+++ b/packages/ui/src/lib/Layout/FormLayout/FormLayout.tsx@@ -64,12 +64,12 @@ export function FormLayout({const flex = layout === 'flex'- let containerClasses = []+ let containerClasses: Array<string> = []containerClasses.push(__styles.size[size])- let labelContainerClasses = []- let dataInputContainerClasses = []+ let labelContainerClasses: Array<string> = []+ let dataInputContainerClasses: Array<string> = []if (layout !== 'horizontal' && !labelLayout && !flex) {labelContainerClasses.push(__styles.labels_horizontal_layout)@@ -198,8 +198,8 @@ export function FormLayout({nonBoxInput && label && layout === 'vertical'? __styles.non_box_data_input_spacing_vertical: nonBoxInput && label && layout === 'horizontal'- ? __styles.non_box_data_input_spacing_horizontal- : ''+ ? __styles.non_box_data_input_spacing_horizontal+ : ''}>{children}diff --git a/packages/ui/src/lib/Overlay/Overlay.tsx b/packages/ui/src/lib/Overlay/Overlay.tsxindex c20067b9494..62af380f754 100644--- a/packages/ui/src/lib/Overlay/Overlay.tsx+++ b/packages/ui/src/lib/Overlay/Overlay.tsx@@ -1,3 +1,5 @@+'use client'+import React, { useEffect, useRef, useState } from 'react'//@ts-ignoreimport { useOnClickOutside } from './../../lib/Hooks'@@ -12,13 +14,7 @@ interface Props {visible?: booleanoverlay?: React.ReactNodechildren?: React.ReactNode- placement?:- | 'bottomLeft'- | 'bottomRight'- | 'bottomCenter'- | 'topLeft'- | 'topRight'- | 'topCenter'+ placement?: 'bottomLeft' | 'bottomRight' | 'bottomCenter' | 'topLeft' | 'topRight' | 'topCenter'onVisibleChange?: anydisabled?: booleantriggerElement?: any@@ -71,9 +67,7 @@ function Overlay({return (<div ref={ref} className={OverlayStyles['sbui-overlay']}>- {placement === 'bottomRight' ||- placement === 'bottomLeft' ||- placement === 'bottomCenter' ? (+ {placement === 'bottomRight' || placement === 'bottomLeft' || placement === 'bottomCenter' ? (<TriggerElement />) : null}<Transition@@ -91,9 +85,7 @@ function Overlay({</DropdownContext.Provider></div></Transition>- {placement === 'topRight' ||- placement === 'topLeft' ||- placement === 'topCenter' ? (+ {placement === 'topRight' || placement === 'topLeft' || placement === 'topCenter' ? (<TriggerElement />) : null}</div>diff --git a/packages/ui/src/lib/theme/themeContext.tsx b/packages/ui/src/lib/theme/themeContext.tsxindex ff7ec212672..338224aad47 100644--- a/packages/ui/src/lib/theme/themeContext.tsx+++ b/packages/ui/src/lib/theme/themeContext.tsx@@ -1,3 +1,5 @@+'use client'+import React, { useLayoutEffect, useMemo } from 'react'import { createContext } from 'react'import defaultTheme from './defaultTheme'