DEV Community 👩‍💻👨‍💻

Rich Field
Rich Field

Posted on • Updated on

Deploying Firebase Rules is super easy

The deployment of my firebase project has been automated since day one.

With one notable exception - the database rules.

A recent feature required considerable changes to the rules and I wanted to have them under source control.

Partly to have a record of all changes and partly as it's easy for clumsy fingers to update / delete rules via the console.

Turns out it's super easy - as most things Firebase are! 😄

Simply define your rules in a .json file, then add a rules property to the firebase.json file that points to it.

{
  "database": {
    "rules": "firebase.database.rules.json"
  },
  "hosting" : {
     ...
  }
}

Then wherever you run simply call the Firebase CLI like this:

firebase deploy --only database

Or if like me you want to deploy and app and database:

firebase deploy --only hosting,database

Note the lack of space after the comma, that caught me out first try!

Top comments (0)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.