Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flamelink/flamelink
JavaScript SDK for integrating with Flamelink CMS 🔥
https://github.com/flamelink/flamelink
cms firebase javascript sdk
Last synced: about 16 hours ago
JSON representation
JavaScript SDK for integrating with Flamelink CMS 🔥
- Host: GitHub
- URL: https://github.com/flamelink/flamelink
- Owner: flamelink
- Created: 2017-09-26T18:31:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T20:30:45.000Z (about 2 years ago)
- Last Synced: 2024-12-15T16:06:52.772Z (8 days ago)
- Topics: cms, firebase, javascript, sdk
- Language: JavaScript
- Homepage: https://flamelink.github.io/flamelink/
- Size: 1.26 MB
- Stars: 192
- Watchers: 19
- Forks: 22
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Flamelink JavaScript SDK
![NPM Version](https://img.shields.io/npm/v/flamelink/latest.svg?colorB=purple&logo=npm&style=flat-square)
![NPM Version](https://img.shields.io/npm/v/flamelink/next.svg?colorB=red&logo=npm&style=flat-square)
![NPM Downloads](https://img.shields.io/npm/dt/flamelink.svg?logo=npm&style=flat-square)
[![](https://data.jsdelivr.com/v1/package/npm/flamelink/badge)](https://www.jsdelivr.com/package/npm/flamelink)> ## **:warning: NOTE :warning:**
>
> Version 0.x.x (flamelink@latest) of the SDK only supports the Firebase Realtime Database, and is being deprecated.
>
> Please consider upgrading to the "@next" version of the SDK (flamelink@next) which supports both Cloud Firestore and the Realtime Database
>
> - [Installation](https://flamelink.github.io/flamelink-js-sdk/#/getting-started)
> - [Migration Guide](https://flamelink.github.io/flamelink-js-sdk/#/migration-guide)
> - [Repository](https://github.com/flamelink/flamelink-js-sdk)
>
> Alternatively please ensure you have specified a fixed version in your package manager file ("flamelink": "0.19.14") to avoid updating to the latest version of Flamelink on your next installation
![logo](https://raw.githubusercontent.com/flamelink/flamelink/master/docs/_assets/icon.svg?sanitize=true)> Easily integrate with your Flamelink CMS.
This SDK is intended to be used in a browser or on a NodeJS server environment.
If you are unfamiliar with Flamelink, please visit our [flamelink.io](https://www.flamelink.io/) website for more info on features, pricing and more.
**NOTE: THIS SDK SUPPORTS THE FIREBASE REALTIME DATABASE ONLY.**
**If you are looking for Cloud Firestore support, please use our [new SDK](https://flamelink.github.io/flamelink-js-sdk) that supports both.**
## Prerequisites
It goes without saying that you will need to have a [Flamelink](https://www.flamelink.io) project for this SDK to be of any use to you.
Apart from the Flamelink project, the only real hard dependency is either the [Firebase JavaScript SDK](https://www.npmjs.com/package/firebase) or [Firebase Admin SDK](https://firebase.google.com/docs/admin/setup), depending on whether you use Flamelink from the browser or server. Take a look at the installation instructions on their README, but in short, just make sure you add `firebase` or `firebase-admin` as a dependency to your project.
Once you have `firebase` installed, you can install `flamelink` using any of the following options (we recommend installing with `npm` or `yarn`):
## Installation
Install with `npm`
```bash
npm install --save flamelink
```or with `yarn`
```bash
yarn add flamelink
```or with a `` tag hosted from any of these CDN's
### jsDelivr
Add the following script tag to the `<body>` of your index.html file:
```html
<script src="//cdn.jsdelivr.net/npm/flamelink/dist/flamelink.js">
```This will always load the latest version of this SDK for you. If you want to load a specific version, you can specify the version number as well (1.0.0 in the example):
```html
```
> See the [jsDelivr website](https://www.jsdelivr.com/?query=flamelink) for more options
### unpkg
Add the following script tag to the `` of your index.html file:
```html
```
This will always load the latest version of this SDK for you. If you want to load a specific version, you can specify the version number as well (1.0.0 in the example):
```html
```
> See the [unpkg website](https://unpkg.com) for more options
## Usage
### Importing/Adding the dependencies
First ensure that you load the `flamelink` package to your file. When using the `` tag version, you will need to load both `firebase` and `flamelink` which will then be globally available on the browser's `window` object.
Depending on your app setup, you can import the package using `require()` statements:
```javascript
var flamelink = require('flamelink');
```or using ES2015/ES6 imports:
```javascript
import flamelink from 'flamelink';
```### Creating your Flamelink app instance
You can create your `flamelink` app instance by passing in an existing `firebaseApp` instance along with all the other `flamelink` config options (if using this option you need to remember to import `firebase` or `firebase-admin` yourself):
```javascript
import * as firebase from 'firebase';
import flamelink from 'flamelink';const firebaseConfig = {
apiKey: '<your-api-key>', // required
authDomain: '<your-auth-domain>', // required
databaseURL: '<your-database-url>', // required
projectId: '<your-project-id>', // required
storageBucket: '<your-storage-bucket-code>', // required
messagingSenderId: '<your-messenger-id>' // optional
};const firebaseApp = firebase.initializeApp(firebaseConfig);
const app = flamelink({ firebaseApp });
```?> **Tip:** Go to your [Firebase console](https://console.firebase.google.com/) to find these config settings.
When using the `firebase-admin` SDK on server-side, you need to specify a `isAdminApp` property along with your `firebaseApp` instance, like this:
```javascript
const admin = require('firebase-admin');
const flamelink = require('flamelink');
const serviceAccount = require('path/to/serviceAccountKey.json');const firebaseConfig = {
credential: admin.credential.cert(serviceAccount), // required
databaseURL: '<your-database-url>', // required
storageBucket: '<your-storage-bucket-code>' // required if you want to your any Storage functionality
};const firebaseApp = admin.initializeApp(config);
const app = flamelink({ firebaseApp, isAdminApp: true }); // Remember `isAdminApp: true` here!!!
```> You can use any of the [different ways to create the admin firebaseApp instance](https://firebase.google.com/docs/admin/setup), as long as you remember to set the `isAdminApp: true` option.
### Using your flamelink app
Once you have an instance of the [`flamelink` app](https://app.flamelink.io), you can start using it to interact with your data stored in your firebase database. Suppose you want to retrieve all your products created under the "Content" section in `flamelink`.
_Using standard Promises:_
```javascript
app.content.get('products')
.then(products => console.log('All of your products:', products))
.catch(error => // handle any errors)
```_Using async-await:_
```javascript
const products = await app.content.get('products');
console.log('All of your products:', products);
```Read our [docs](https://flamelink.github.io/flamelink) for more specifics!
> 🔥🔥🔥 **Flame on!!** 🔥🔥🔥