File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
packages/adapter-firebase/src Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { initializeApp , getApps , FirebaseOptions } from "firebase/app"
2
+
3
+ export default function getFirebase ( firebaseOptions : FirebaseOptions ) {
4
+ const apps = getApps ( )
5
+ const app = apps . find ( ( app ) => app . name === firebaseOptions . projectId )
6
+ if ( app ) {
7
+ return app
8
+ } else {
9
+ return initializeApp ( firebaseOptions )
10
+ }
11
+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import type {
25
25
} from "next-auth/adapters"
26
26
27
27
import { getConverter } from "./converter"
28
+ import getFirebase from "./getFirebase"
28
29
29
30
export type IndexableObject = Record < string , unknown >
30
31
@@ -39,7 +40,7 @@ export function FirestoreAdapter({
39
40
emulator,
40
41
...firebaseOptions
41
42
} : FirebaseOptions & FirestoreAdapterOptions ) : Adapter {
42
- const firebaseApp = initializeApp ( firebaseOptions )
43
+ const firebaseApp = getFirebase ( firebaseOptions )
43
44
const db = getFirestore ( firebaseApp )
44
45
45
46
if ( emulator ) {
You can’t perform that action at this time.
0 commit comments