svelte-on-fire
v0.4.0
Published
Provides convenience methods to simplify your Svelte/Firebase app development.
Downloads
18
Readme
Svelte On Fire
Provides convenience methods to simplify your Svelte/Firebase app development.
Basics
- Pre-created Svelte store for Firebase auth
- Utility function to create additional Svelte stores that only return data when the user is authenticated
- Convenience methods for easily querying Firestore
Quick Start
Install from NPM
npm install svelte-on-fire
And do not forget to install firebase dependencies
npm install firebase
Create a project at https://firebase.google.com/ and grab your web config. Create a .env file in your respository like:
VITE_FIREBASE_API_KEY=<your API key>
VITE_FIREBASE_AUTH_DOMAIN=<your auth domain>
VITE_FIREBASE_PROJECT_ID=<your project id>
VITE_FIREBASE_STORAGE_BUCKET=<your storage bucket>
VITE_FIREBASE_MESSAGE_SENDER_ID=<your sender id>
VITE_FIREBASE_APP_ID=<your app id>
Opt-in to the following services from the Firebase console to run the demo.
- Email/Password Login under authentication -> sign-in method
- Cloud Firestore under database. Make sure it's in test mode (or provide write access to the
users/
collection using Security Rules).
Usage
Copy the contents of src/routes/+page.svelte
and src/routes/firebase.ts
and into your own project. This is a basic example of how to use the library.
Note: It's highly recommended to install the Firebase emulators and run them locally. This will allow you to test your app without having to deploy it to Firebase.
Publishing
- Run
npm run build
to build the library - Run
cd package
to go into the package directory - Run
npm publish
to publish the package to NPM