Closed dahburj closed 3 years ago
Hey @dahburj, I haven't used the Client JS SDK in SvelteKit yet, but I believe you need to use it after checking that your are in a browser
env with https://kit.svelte.dev/docs#modules-$app-env and then also onMount
with https://svelte.dev/docs#onMount
Can you share the reason you closed this Issue?
I closed it because I got it to work within half an hour of posting the issue; the steps you mention was my OG game plan, however, let's just say it was a lot easier to plan than to execute😂.. But I finally found a way to get to import into the client side without the ton of errors I kept hitting. For any/all interested; I got it to work by using the router=browser variable in each of the functions, and; more importantly, to get it to run AND build without errors I had to import the firebase modules at the beginning of each/every function.
if (router) {
const { getFunctions, httpsCallable } = await import("firebase/functions");
const functionsN = getFunctions();
await signUpWithEmailPassword(signupEmail, signupPassword);
const fCreateUser = httpsCallable(functionsN, "createUser");
await fCreateUser({ name: userFullName })
.then(async (result) => {
console.log(result);
const data = result.data;
console.log(data);
notificationMessage.set({
message: "Welcome back!",
type: "toast--link",
});
disableAction = false;
await goto("/dashboard");
})
.catch(function (error) {
console.log(error);
});
}
P.S. I reached many-a similar problem trying to import firestore, and as my process went auth, functions, firestore, I felt defeated and settled on writing out my store middleware as a serious of firebase https functions, it works fine and I feel as though with bundling and caching maybe it won't be that bad, nonetheless, any advice/input you may have on the matter will be appreciated greatly🙋🏻♂️
I will probably write a guide on Firebase with SSR tools once I go through the motions of getting it to work in my own apps. I currently only have the new firebase-admin@exp
lib working in SvelteKit Endpoints, so no need for trickery checking runtimer (browser/server) or waiting for component mounts.
That sounds amazing, I feel as though I came close to the same thing but my experience with svelte-kit started when I found this adapter (in all seriousness twas a God send). My train of thought was to convert my datastore functions (now in the server running as httpscallable and using the firebase-admin@exp) into something along the lines of data bundles , setting each's timeout/cache accordingly and also a nice endpoint, but like I said, my experience with svelte-kit is pretty much nil; plus, I cant say I was/am too keen on diving into it because of the fact that using that method would entail changing up the "rewrites" in firebase.json and I'm not tring messing with the beauty of what your adapter does at this point in my development road map .😂 Do let me know when/if you decide to share those Sveltekit Endpoints!
I will add examples to the docs as I resolve the issues - https://github.com/jthegedus/svelte-adapter-firebase/issues/101
Describe the bug Well I don't if it's a bug or if I'm doing something wrong, but I keep getting all these crazy errors and build fails when I try to use/import firebase functions from any client side script. I have a multitude of Firebase Functions (besides the svelte kit one) that I'd like to utilize, but I have no idea how, any help would be greatly appreciated.
To Reproduce Steps to reproduce the behavior:
Screenshots
Additional context Error message below: Adapter configuration: {"firebaseJson":"firebase.json","sourceRewriteMatch":"**"} Writing Cloud Function server assets to: functions/sveltekit Erasing static asset dir before processing: public Writing client application to: public Prerendering static pages to: public