# Firebase Phone Number Authentication in Kotlin/Wasm (Part 3)

DevFeed: [Firebase Phone Number Authentication in Kotlin/Wasm (Part 3)](<https://devfeed.tech/articles/firebase-phone-number-authentication-in-kotlin-wasm-part-3-55442.md>)

Original publisher: [Read original article](<https://proandroiddev.com/kotlin-wasm-auth-part-3-phone-sign-in-9b47f1993940?source=rss----c72404660798---4>)

Author: Tomislav Mladenov

Published: 2026-09-19T16:03:23Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [Firebase](<https://devfeed.tech/topics/firebase.md>), [WebAssembly](<https://devfeed.tech/topics/web-assembly.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Firebase console](<https://devfeed.tech/topics/firebase-console.md>), [Wasm components](<https://devfeed.tech/topics/wasm-components.md>)

Tags: [auth](<https://devfeed.tech/tags/auth.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [billing](<https://devfeed.tech/tags/billing.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [firebase-console](<https://devfeed.tech/tags/firebase-console.md>), [firebaseauthentication](<https://devfeed.tech/tags/firebaseauthentication.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-wasm](<https://devfeed.tech/tags/kotlin-wasm.md>), [number](<https://devfeed.tech/tags/number.md>), [phone](<https://devfeed.tech/tags/phone.md>), [phone-authentication](<https://devfeed.tech/tags/phone-authentication.md>), [recaptcha](<https://devfeed.tech/tags/recaptcha.md>), [region](<https://devfeed.tech/tags/region.md>), [regions](<https://devfeed.tech/tags/regions.md>), [requires](<https://devfeed.tech/tags/requires.md>), [series](<https://devfeed.tech/tags/series.md>), [sign-in](<https://devfeed.tech/tags/sign-in.md>), [sms](<https://devfeed.tech/tags/sms.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tokens](<https://devfeed.tech/tags/tokens.md>), [wasm](<https://devfeed.tech/tags/wasm.md>), [webassembly](<https://devfeed.tech/tags/webassembly.md>)

## AI overview

Firebase phone sign-in in Kotlin/Wasm needs Blaze billing enabled and the desired SMS region allowed in Firebase settings; otherwise attempts fail with `auth/billing-not-enabled` or `auth/operation-not-allowed`. The flow adds bindings for `RecaptchaVerifier`, `PhoneAuthProvider` and `signInWithCredential`, plus a DOM element for the verifier. Each attempt should clear the previous verifier and create a fresh one because reCAPTCHA tokens are single-use; reusing one can cause retries to fail with `auth/invalid-app-credential`. Sign-in first verifies the phone number and stores its verification ID, then exchanges that ID and the SMS code for a credential and signed-in user. For development, a console-registered fictional number and fixed code can be used with app verification disabled, avoiding captcha, real SMS and quota use; the excerpt cautions against shipping with that switch enabled.

## Source excerpt

Part 3 of the Wasm series is phone sign-in, and the Kotlin code is once again the easy half. Before you write a line, know the three Firebase console traps. Phone auth now requires the Blaze plan, and until billing is on every attempt fails with auth/billing-not-enabled, fictional test numbers included. The SMS region policy (Authentication -> Settings -> SMS region policy) denies all regions by default and returns auth/operation-not-allowed until you allow yours. And reCAPTCHA tokens are single-use, which we'll get to in the code. Console sorted? Good, the Wasm part is pleasantly small. Phone sign-in needs four things our part 1 bindings didn't have: a reCAPTCHA verifier, the phone provider, a credential sign-in function and the user's phone number. All of them go into the same @file:JsModule("firebase/auth") file: external class RecaptchaVerifier( auth: Auth, container: String, parameters: JsAny, ) : JsAny { fun clear() } external class PhoneAuthProvider(auth: Auth) : JsAny { fun verifyPhoneNumber(phoneNumber: String, applicationVerifier: RecaptchaVerifier): Promise<JsString> companion object { fun credential(verificationId: String, verificationCode: String): JsAny } } external fun signInWithCredential(auth: Auth, credential: JsAny): Promise<UserCredential> Two small js() helpers stand in for what would be dynamic on Kotlin/JS: one builds the verifier options, the other flips Firebase's testing switch: private fun invisibleRecaptchaParams(): JsAny = js("({ size: 'invisible' })") private fun disableAppVerificationForTesting(auth: Auth): Unit = js("{ auth.settings.appVerificationDisabledForTesting = true; }") The verifier also wants a real DOM element to attach to, and our UI is a Compose canvas, so we create a plain div for it once: private fun recaptchaContainer(): String { if (document.getElementById(RECAPTCHA_CONTAINER_ID) == null) { val container = document.createElement("div") container.setAttribute("id", RECAPTCHA_CONTAINER_ID) document.body?.appendChild(cont