Setting up Tanam for the first time requires a bit of Firebase knowledge. The easiest way to get started is to clone the tanam-starter repository and just update the Firebase configuration from step 7 below.
First, you need to set some things up in the Firebase console. Create a Firebase project for your new CMS site (or choose an existing).
- Enable Google Auth - Enable Google Authentication and follow the instructions.
- Enable Firestore - the first time after you have created a Firebase project, you need to create a Firestore database for Tanam. Go to "Database" in the Firebase console and click "Create Database"
- Set up hosting - this step is optional, but you will most likely want to connect you own domain to your Firebase project. Go to "Hosting" in the Firebase console and click "Get started" and follow the instructions.
- Switch to Blaze Plan - Tanam requires the project to be on Blaze plan for the cache management.
- Add web app - get the Firebase web config by adding a web app from the project dashboard or go ot the settings page. You will need this configuration later when you setup your project.
If you choose to not connect a custom domain, your website will only be available on the default hosting domain: https://your-project-id.firebaseapp.com/ and https://your-project-id.web.app/
This section explains how you can set up a new Tanam project from scratch. You can also fork the tanam-starter project and skip most of the steps that are already preconfigured for you. If you do that, you can practically skip directly to step 7.
- Install Firebase CLI:
firebase-tools
- Run
firebase init
and follow the instructions- Enable all features (realtime database, firestore, hosting, functions, cloud storage)
- Use TypeScript for your functions
- Rewrite all URLs to
index.html
- Delete all files in your
public/
folder. You can put a.gitkeep
there to make sure it exists - Edit
firebase.json
and replace the rewrite toindex.html
with a rewrite to thetanam
cloud function.
"rewrites": [
{
"source": "**",
"function": "tanam"
}
]
- Add NPM dependency
tanam@latest
$ cd functions
$ npm i --save tanam@latest
- Update
.firebaserc
and add your project ID as the default project
{
"projects": {
"default": "your-project-id"
}
}
- Copy paste the code below into your
index.ts
file.- Replace (and add any) email that should have access to the site. You can assign the roles (superAdmin, admin, publisher) for different access of content. Make sure that at least someone is the "superAdmin".
- Replace the
firebaseApp
with your own web configuration that you got when adding a web app in the Firebase console
import * as tanam from 'tanam';
tanam.initializeApp({
users: {
"[email protected]": "superAdmin",
},
firebaseApp: {
apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
authDomain: "your-project-id.firebaseapp.com",
databaseURL: "https://your-project-id.firebaseio.com",
projectId: "your-project-id",
storageBucket: "your-project-id.appspot.com",
messagingSenderId: "0123456789"
},
});
export * from 'tanam';