loading...

Deploying Firebase Rules is super easy

kildareflare profile image Rich Field Updated on ・1 min read

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!

Posted on Mar 6 by:

kildareflare profile

Rich Field

@kildareflare

Full stack remote dev that prefers the front end. I build web applications for NPOs and businesses large and small.

Discussion

markdown guide