AquaRead ← Back to the app

Create your own library

A library is a free Google Firebase Realtime Database that holds your books as text. Anyone you give the link to can add it in AquaRead (Library → Libraries) and listen. It takes about 10 minutes and needs a Google account.

Create a Firebase project

Go to console.firebase.google.com, sign in, click Create a project, give it a name and finish the wizard. Google Analytics isn't needed.

Create the Realtime Database

In the left menu open Build → Realtime Database and click Create Database. Pick the location closest to your readers and start in locked mode (you'll set the rules in step 4).

It must be Realtime Database, not Firestore. They look similar but are different products.

Copy your database URL

On the Data tab, the address at the top is your library's link. It looks like one of these:

https://my-library-default-rtdb.firebaseio.com
https://my-library-default-rtdb.europe-west1.firebasedatabase.app

Use it exactly as shown, without a path after it. This is what people paste into AquaRead.

Set the rules

Open the Rules tab, replace everything with this, and click Publish. It lets anyone read your books but nobody write. You edit the data yourself in the Firebase console, which isn't limited by these rules.

{
  "rules": {
    ".read": false,
    ".write": false,
    "library": { ".read": true },
    "books": { ".read": true },
    "bookTexts": { "$bookId": { ".read": true } }
  }
}

Book texts can only be read one at a time by id, so nobody can download everything in one request.

Add your books

AquaRead expects this layout. The easiest start: on the Data tab click the ⋮ menu → Import JSON and choose a file containing the example below (save it as library.json). Importing replaces what's at that spot, so do this on a new, empty database. After that, add or edit books with the + buttons on the Data tab.

{
  "library": {
    "name": "My Fantasy Library",
    "description": "Public-domain fantasy stories."
  },
  "books": {
    "crystal-cavern": {
      "title": "The Crystal Cavern",
      "author": "A. Author",
      "description": "A short description.",
      "voice": "en-US-AndrewNeural",
      "speed": 1,
      "publishedAt": 1790000000000
    }
  },
  "bookTexts": {
    "crystal-cavern": "Chapter 1. The full text of the book goes here..."
  }
}
WhereRule
books/<id>The id (the key) uses only letters, numbers, - and _, up to 64 characters.
title, authorRequired. Up to 200 and 100 characters.
descriptionOptional, up to 2000 characters.
voice, speedOptional. An AquaRead voice name (otherwise Ava is used) and a number from 0.25 to 3.
publishedAtOptional number in milliseconds. Newest books are shown first (the app shows the newest 100).
bookTexts/<id>The full text as one string, using the same id as the book. Up to 200,000 characters.
libraryOptional name, description and website shown on your library's card.

Test it in your browser

Open your URL with /books.json on the end, for example https://my-library-default-rtdb.firebaseio.com/books.json. You should see your books as JSON. If you see Permission denied, go back to step 4.

Add it to AquaRead

Go to AquaRead → Library → Libraries, paste your URL, optionally type a nickname, and press Connect. Sign in and the library is saved to your account. Share the URL with anyone who should read it.

Optional: let AquaRead members publish to your library

People who joined your library and are signed in to AquaRead can send books to it (Publish → choose your library). This only works if you allow it in the rules, and you choose how:

Option A: publish instantly. In the Rules tab, replace your "books" and "bookTexts" lines with this. Books appear right away, and nobody can overwrite or delete an existing book. Remove unwanted ones in the Data tab.

"books": {
  "$id": {
    ".write": "!data.exists()",
    ".validate": "$id.matches(/^[A-Za-z0-9_-]{1,64}$/) && newData.hasChildren(['title','author','publishedAt'])",
    "title": { ".validate": "newData.isString() && newData.val().length <= 200" },
    "author": { ".validate": "newData.isString() && newData.val().length <= 100" },
    "description": { ".validate": "newData.isString() && newData.val().length <= 2000" },
    "voice": { ".validate": "newData.isString() && newData.val().length <= 64" },
    "speed": { ".validate": "newData.isNumber() && newData.val() >= 0.25 && newData.val() <= 3" },
    "publishedAt": { ".validate": "newData.isNumber()" },
    "chars": { ".validate": "newData.isNumber()" },
    "ownerUid": { ".validate": "newData.isString() && newData.val().length <= 64" },
    "rightsConfirmedAt": { ".validate": "newData.isNumber()" },
    "$other": { ".validate": false }
  },
  ".read": true
},
"bookTexts": {
  "$bookId": {
    ".read": true,
    ".write": "!data.exists()",
    ".validate": "newData.isString() && newData.val().length <= 200000"
  }
}

Option B: review first. Add this next to your other rules instead. Sent books land in a private submissions node only you can read. To approve one, add it under books and bookTexts in the Data tab (see step 5) and delete the submission.

"submissions": {
  "$id": {
    ".write": "!data.exists()",
    ".validate": "$id.matches(/^[A-Za-z0-9_-]{1,64}$/) && newData.hasChildren(['title','author','text']) && newData.child('title').isString() && newData.child('title').val().length <= 200 && newData.child('author').isString() && newData.child('author').val().length <= 100 && newData.child('text').isString() && newData.child('text').val().length <= 200000"
  }
}

Be aware: Firebase can't check AquaRead accounts, so the sign-in requirement is enforced by the app only. Anyone who knows your database URL could send a book in with their own code. Option B is the safer choice for a public library. Leave both out and nobody can add books but you.

Troubleshooting

Firebase's console wording can change a little over time. Free plans have storage and download limits, so check Firebase's pricing page. You are responsible for the rights to everything in your library, and AquaRead doesn't host, review or endorse it. Never put passwords or private data in it, because everything in it is public.