File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -64,17 +64,16 @@ export default class IsomorphicClerk {
64
64
static #instance: IsomorphicClerk ;
65
65
66
66
static getOrCreateInstance ( params : NewIsomorphicClerkParams ) {
67
- if ( ! this . #instance) {
67
+ // During SSR: a new instance should be created for every request
68
+ // During CSR: use the cached instance for the whole lifetime of the app
69
+ // This method should be idempotent in both scenarios
70
+ if ( ! inClientSide ( ) || ! this . #instance) {
68
71
this . #instance = new IsomorphicClerk ( params ) ;
69
72
}
70
73
return this . #instance;
71
74
}
72
75
73
76
constructor ( params : NewIsomorphicClerkParams ) {
74
- if ( IsomorphicClerk . #instance) {
75
- throw new Error ( 'An IsomorphicClerk instance already exists. Use IsomorphicClerk.getOrCreateInstance instead' ) ;
76
- }
77
-
78
77
const { Clerk = null , frontendApi, options = { } } = params || { } ;
79
78
this . frontendApi = frontendApi ;
80
79
this . options = options ;
You can’t perform that action at this time.
0 commit comments