Skip to content

Commit

Permalink
FR-15099 - Use shared store ref between page wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Aug 14, 2024
1 parent 23c85df commit 963ecf4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/nextjs/src/utils/initializeFronteggApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,21 @@ const initializeFronteggApp = ({
tenantsState: tenantsState as AuthState['tenantsState'],
};

const sharedStore = createStore({
context: contextOptions,
storeHolder,
previewMode: options.previewMode,
name: appName ?? 'default',
urlStrategy: options.urlStrategy,
builderMode: false,
initialState: {
auth: authOptions,
},
});
let sharedStore = storeHolder.store;
if (!sharedStore) {
sharedStore = createStore({
context: contextOptions,
storeHolder,
previewMode: options.previewMode,
name: appName ?? 'default',
urlStrategy: options.urlStrategy,
builderMode: false,
initialState: {
auth: authOptions,
},
});
storeHolder.store = sharedStore;
}

let createdApp;
try {
Expand Down

0 comments on commit 963ecf4

Please sign in to comment.