This is an example or POC of how to use SvelteKit with Firebase Auth and Firestore and how to model your Firestore for multi-tenancy. It also includes Tailwind CSS integration as a bonus.
The app uses Firebase emulator for Firestore and Firebase Auth locally. To run do pnpm i && pnpm start
. The app does not follow any recommended structure, only minimal to get things to work. There is also Firebase functions project included, but it's empty because no cloud functions are used in this example. The app uses SvelteKit demo as starting project.
Handle any errors. Happy path all the way!
To create new user and company pair in Firebase emulator run the command when the emulator is running.
$ ./create_org_and_user.js --name "Google" --email [email protected]
Do it at least twice so you get at least two companies.
IMPORTANT
In order for Firebase admin to connect to Firebase emulator you have to export a couple of system variables. See .env
file.
Getting this Line must be greater than or equal to 1, got -1
error? Me too and I honestly have no idea why or what it means.
Does the app crash in dev server with <Header> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules
error? For me too and I have no idea why.
It's most likely some kind of Vite-related ESM error. See https://github.com/sveltejs/kit/issues/2670
I take no responsibility if you use the examples and something goes wrong. Use at your own risk and use your judgement.
If you want to learn more interesting things feel free follow me on Twitter or step by my blog - codechips.me.