Skip to content

Commit 356787e

Browse files
author
Stefanos Anagnostou
committed
feat(remix): Support v2_errorBoundary future flag
1 parent 019992f commit 356787e

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

.changeset/thirty-humans-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/remix': minor
3+
---
4+
5+
Introduce `V2_ClerkErrorBoundary` to support `v2_errorBoundary` future flag
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { isRouteErrorResponse, useRouteError } from '@remix-run/react';
2+
import React from 'react';
3+
4+
import { Interstitial } from './Interstitial';
5+
6+
/*
7+
* V2_ClerkErrorBoundary needs the `v2_errorBoundary` future flag to be enabled.
8+
*/
9+
export function V2_ClerkErrorBoundary(RootErrorBoundary?: React.ComponentType) {
10+
return () => {
11+
const error = useRouteError();
12+
13+
if (isRouteErrorResponse(error)) {
14+
const { __clerk_ssr_interstitial_html } = error?.data?.clerkState?.__internal_clerk_state || {};
15+
if (__clerk_ssr_interstitial_html) {
16+
return <Interstitial html={__clerk_ssr_interstitial_html} />;
17+
}
18+
}
19+
20+
if (!RootErrorBoundary) {
21+
return undefined;
22+
}
23+
24+
return <RootErrorBoundary />;
25+
};
26+
}

packages/remix/src/client/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './RemixClerkProvider';
22
export { ClerkApp } from './ClerkApp';
33
export * from './ClerkCatchBoundary';
4+
export * from './V2_ClerkErrorBoundary';
45
export { WithClerkState } from './types';

0 commit comments

Comments
 (0)