Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-root-not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Add root-level not-found page so /404 renders a branded page instead of the default Vercel error screen
58 changes: 26 additions & 32 deletions core/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';
import { clsx } from 'clsx';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { NextIntlClientProvider } from 'next-intl';
import { setRequestLocale } from 'next-intl/server';
import { NuqsAdapter } from 'nuqs/adapters/next/app';
import { cache, PropsWithChildren } from 'react';

import '../../globals.css';

import { fonts } from '~/app/fonts';
import { CookieNotifications } from '~/app/notifications';
import { Providers } from '~/app/providers';
import { client } from '~/client';
Expand Down Expand Up @@ -140,34 +136,32 @@ export default async function RootLayout({ params, children }: Props) {
const privacyPolicyUrl = rootData.data.site.settings?.privacy?.privacyPolicyUrl;

return (
<html className={clsx(fonts.map((f) => f.variable))} lang={locale}>
<body className="flex min-h-screen flex-col">
<NextIntlClientProvider>
<ConsentManager
isCookieConsentEnabled={isCookieConsentEnabled}
privacyPolicyUrl={privacyPolicyUrl}
scripts={scripts}
>
<NuqsAdapter>
<AnalyticsProvider
channelId={rootData.data.channel.entityId}
isCookieConsentEnabled={isCookieConsentEnabled}
settings={rootData.data.site.settings}
>
<Providers>
{toastNotificationCookieData && (
<CookieNotifications {...toastNotificationCookieData} />
)}
{children}
</Providers>
</AnalyticsProvider>
</NuqsAdapter>
</ConsentManager>
</NextIntlClientProvider>
<VercelComponents />
<ContainerQueryPolyfill />
</body>
</html>
<>
<NextIntlClientProvider>
<ConsentManager
isCookieConsentEnabled={isCookieConsentEnabled}
privacyPolicyUrl={privacyPolicyUrl}
scripts={scripts}
>
<NuqsAdapter>
<AnalyticsProvider
channelId={rootData.data.channel.entityId}
isCookieConsentEnabled={isCookieConsentEnabled}
settings={rootData.data.site.settings}
>
<Providers>
{toastNotificationCookieData && (
<CookieNotifications {...toastNotificationCookieData} />
)}
{children}
</Providers>
</AnalyticsProvider>
</NuqsAdapter>
</ConsentManager>
</NextIntlClientProvider>
<VercelComponents />
<ContainerQueryPolyfill />
</>
);
}

Expand Down
14 changes: 14 additions & 0 deletions core/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { clsx } from 'clsx';
import { PropsWithChildren } from 'react';

import '../globals.css';

import { fonts } from '~/app/fonts';

export default function RootLayout({ children }: PropsWithChildren) {
return (
<html className={clsx(fonts.map((f) => f.variable))} lang="en">
<body className="flex min-h-screen flex-col">{children}</body>
</html>
);
}
16 changes: 16 additions & 0 deletions core/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default function RootNotFound() {
return (
<div className="flex min-h-screen flex-col items-center justify-center bg-[hsl(var(--background))] text-[hsl(var(--foreground))]">
<h1 className="font-heading text-4xl font-medium">Page not found</h1>
<p className="mt-4 text-lg text-[hsl(var(--contrast-400))]">
The page you are looking for could not be found.
</p>
<a
className="mt-6 inline-flex items-center text-[hsl(var(--foreground))] underline underline-offset-4 hover:no-underline"
href="/"
>
Go to homepage
</a>
</div>
);
}