3 ms·
> I love Firebase Authentication, it's such an easy way to add auth to side projects. It's easy to use but it adds 55kB gzip to your project. https://bundleph
by pier25 6y ago
> I love Firebase Authentication, it's such an easy way to add auth to side projects.
It's easy to use but it adds 55kB gzip to your project.
https://bundlephobia.com/result?p=@firebase/auth@0.16.4 https://bundlephobia.com/result?p=@firebase/auth@0.16.4
A couple of comments on the Svelte code.
1) It doesn't makes much sense to use onMount() with listenForAuthChanges(). Just modify the currentUser writable whenever onAuthStateChanged() has an update. Now simply import and use $currentUser in your components.
2) You don't need to use currentUser.subscribe() from your .svelte files as you can use the reactive $: notation for this. You can, if it makes more sense to you, but I wouldn't say it's idiomatic.
- ampdepolymerase 6y agoRe 1) Where should you put the code to initialize the SDK? Code that ideally should only be ran once in the entire lifecycle of the page. For Firebase, will ES modules help with code splitting? The new Svelte kit framework is built by Vite (runs on ES build underneath).
- pier25 6y agoIf you have code in say store.js it will triggered whenever the file is imported the first time. I also trigger init code from my entry point (eg: main.js).
- akiselev 6y agoI use a dynamic `import()` in the login form submit handler with an initialization flag. Code splitting is handled by the bundler