Hello I'm trying to use firebase in compose web ...
# compose-web
r
Hello I'm trying to use firebase in compose web I've included the firebase npm package in build.gradle.kts
Copy code
implementation(npm("firebase", "10.7.1"))
created a file
firebase.kt
Copy code
fun FIREBASE_CONFIG(): String = js(
    """
    ({
        apiKey: '',
        authDomain: '',
        projectId: '',
        storageBucket: '',
        messagingSenderId: '',
        appId: '',
    })
"""
)

@JsModule("firebase/app")
external object FirebaseApp {
    fun initializeApp(config: String): FirebaseApp
}


@JsModule("firebase/auth")
external object FirebaseAuth {
    fun getAuth(app: FirebaseApp): FirebaseAuth
    fun connectAuthEmulator(auth: FirebaseAuth, url: String)
}
initialized in
App.kt
Copy code
val firebase = FirebaseApp.initializeApp(FIREBASE_CONFIG())
I get this error in the browser
FirebaseError: Firebase: Need to provide options, when not being deployed to hosting via source
After trying to create a JS object using the solutions in this https://stackoverflow.com/questions/28150124/javascript-anonymous-object-in-kotlin Using this method listed in the answers
Copy code
inline fun jsObject(init: dynamic.() -> Unit): dynamic {
    val o = js("{}")
    init(o)
    return o
}
I get
Unsupported [Dynamic types are not supported in this context]
Maybe I'm taking this all wrongly, need some pointers, disclaimer I'm trying out kotlin/wasm for the first time, haven't used kotlin/js before too
d
Not sure if this will help you, but https://github.com/bitspittle/firebase-kotlin-bindings is the result of some experimentation I did getting firebase to work in my own project
(Also this channel has almost 2,000 users so in the future you should probably keep your top message short and create a thread to dump your code and question details in)
r
Thanks, I'd check out. I'd be sure to move extra details in thread next time
👍 1
d
Good luck poking around. Feel free to ask here if you have any questions!
👍 1
j
Curious, were you able to make it work? :)
d
@Joel Denke are you trying to do this in your own project?
j
@David Herman I am intending to give it a go once I enable wasm target, using FIrebase for Android and iOS myself. Hence curious 🙂
d
Feel free to ping me when you do!
r
Other compose web issues, I think prevented me from continuing. @Joel Denke
👍 1
😢 1
I found my own question via a google search, forgot I even tried this in the past
😅 1
118 Views