Invoice
Invoice
Bachelor of Engineering
Information Technology
Bachelor’s Thesis
20 May 2022
Abstract
The purpose of the thesis is to evaluate Firebase, and Supabase which are
platforms that provide developers with products and services with the goal of
helping to build applications. The platforms were compared under different
criteria such as features, performance, products, prices, and stability in order to
identify the advantages and disadvantages of each platform. The evaluation
was done for WeDance, a non-profit social network for dancers. It was done
with the aim of providing WeDance the information required to make the
decision to switch between the two platforms based on the necessities of the
company.
The research was carried out by reviewing existing literature to gain proper
insight on the topic. Additionally, two identical progressive web applications
were built using Firebase and Supabase. The main functionality of the
application was to send users daily weather reports for locations users had
specified. The goal was achieved by using different back-end services such as
authentication, social integration, storage, and scheduled jobs.
The results reveal that selecting a more suitable platform between the two is
dependent on the use case of the project. For instance, Supabase offers a
relational database, as well as full-text search capabilities which can be great
for projects that make lots of queries. Firebase on the other hand offers a
NoSQL database with offline support which can be great for building
progressive web applications.
1 Introduction 1
2 Research Design 2
4 Firebase 20
5 Supabase 28
6 Implementation 32
7 Results 47
8 Conclusion 57
References 58
List of Abbreviations
CAGR: Compound Annual Growth Rate. It is the mean annual growth rate
of an investment over a specified period longer than one year.
CRUD: Create, Read, Update, and Delete. They are the four basic
operations performed on stored data.
SSG: Static Site Generator. It is a tool that generates static HTML pages
from templates and raw data.
UI: User Interface. The way through which a person can interact with a
software application or a hardware device.
1 Introduction
In today's age, the web is an essential part of people's lives. With the growth of
technology, web development has become increasingly advanced.
Consequently, writing software for the web has become more sophisticated. To
alleviate the challenges that arise when writing software for the web, there
exists a plethora of software tools that developers can utilize to help simplify
and speed up the process of building a web application. The term software tool
encompasses a large spectrum of development tools covering anything from
text editors to software testing tools. This thesis is mainly going to be focusing
on application development tools or services that help to produce web
applications more efficiently, in particular Firebase and Supabase.
Which development tool is the most viable option for WeDance? To help
answer this question, an application with two different backends but similar
features was built using both Firebase and Supabase. The frontend was then
implemented using [Link], a development framework built on [Link]. As part
of the development process, the examination was carried out based on
products, stability, features, performance, and pricing of the services.
Additionally, both tools were further examined from the perspective of
Progressive Web Apps (PWAs), to decide which platform offered better services
2
Overall, this paper contains four sections. Following the introduction, chapter 2,
3, 4, 5 discusses modern web development approaches, PWAs, and Backend-
as-a-Service (BaaS). Chapters 6 and 7 focus on comparing Firebase and
Supabase as part of the development process. Lastly, chapter 8 concludes the
thesis.
2 Research Design
This section lays out the research design or blueprint for the case study. It helps
identify the research questions, and the overall objectives. In addition, it clarifies
the approach or method used for conducting the research and acquiring data. In
doing so, it aims to ensure that the results obtained can be effectively attributed
to the research problem without any ambiguity [2].
Before defining the objectives, the main research question was deconstructed
into sub-questions to gain a better understanding of the question or problem.
The research question in hand: Supabase vs Firebase: Evaluation of
performance and development of Progressive Web Apps.
● What are the advantages or disadvantages of either one over the other?
● Which of the two offers better PWA support?
The sub-questions break down the main question into two different parts to help
clarify what exactly is being asked as the project question, and to help identify
the specific strategy needed to arrive at a conclusion for the question in hand.
3
The main research question demands the comparison of two different software
service providers, with the aim of discovering new information or arriving at a
conclusion, therefore comparative research was carried out. The logical
approach used was to deductively arrive to a specific conclusion from existing
theory.
The general steps taken to conduct the research for the project is outlined in
figure 1. The overall process is composed of four major parts. As part of the
research process, information relating to the current state of the topic was also
analyzed. The tools currently being used were highlighted, and the weaknesses
identified with the current system by the founder of the case company, WeDance,
were gathered.
Web applications generally consist of a frontend and a backend. They both play
a crucial role in forming a fully functional web application. However, they each
play a different role and are easily distinguishable. The word frontend is a
commonly used term amongst developers and is interchangeable with client-
side. The term is used to describe everything a user can visualize and interact
with. For instance, when visiting an E-commerce (electronic commerce) site
such as Amazon, the list of items that users can interact with by browsing and
adding in shopping carts is handled in the frontend. In Fact, it may seem as if
everything is handled in the frontend, but most of the workload is generally
managed in the backend. [5]
It is important to note that, although the backend is very crucial, it is not always
necessary to have a backend when developing a web application. The
necessity of a backend is dependent on the use case of the application. In
certain cases, it might not be a requirement for an application to fetch or store
data. For example, a simple portfolio site that serves static or fixed content can
be built mainly using frontend technology, although a cloud service would still
be required for hosting static files.[5]
HTML, CSS and JavaScript are the basic building blocks used in frontend web
development. When working with large frontend web applications, libraries or
frameworks that provide additional support are generally used. Some of the
most popular choices include React, [Link], and Angular [9]. All these
frameworks provide a foundation or boilerplate on which developers can build
applications that are scalable and easily maintainable [7].
7
Figure 2 provides some interesting information about the most used web
frameworks by developers, as of 2021. According to the survey, 40.41 percent
of respondents use React, making it one of the most used libraries. Amongst
the top JavaScript frameworks mentioned in the survey, Angular and [Link] are
ranked in fourth and fifth place respectively. In third place, Express is ranked at
23.82 percent making it the only backend framework in the top five.
8
The backend refers to all the technology required to handle incoming requests
from the client, process them, and then send a response back. The method in
which the frontend communicates with the backend is via Hypertext Transfer
Protocol (HTTP) requests. Typically, the backend consists of three major parts.
The first major part is the server, which is the computer program or device that
listens for incoming requests. The second major part is the app, which is the
application program running on the server that receives requests, queries data
from the database, and then sends a response to the client. Lastly, the
remaining major part is the database, which is used to persist and organize
data.[10]
[Link] is an open source React framework built by Vercel and the open-source
community. It offers the fundamental building blocks needed to develop web
apps more efficiently. Building web applications involves the consideration of
common application requirements, such as user interface (UI), routing, data
fetching, rendering, integration, infrastructure, performance, scalability, and
developer experience. [12]
9
Integration involves the consideration of how the application interacts with third-
party services such as authentication or payment. Infrastructure is where
application code is stored, deployed, and run. Performance looks at how the
experience of the end-user can be improved. Scalability considers how an
application will adjust as traffic and data increase overtime. Lastly, developer
experience describes the experience of developer teams maintaining and
dealing with a code base.
React is a JavaScript library used for building interactive and composable user
interfaces. The library offers helpful JavaScript functions for building self-
encapsulated component-based UI, with the ability to manage its own state.
Component logic is written in JavaScript but React offers JavaScript extensible
markup language (JSX), which makes writing markup that resembles HTML
syntax possible inside React components, and Classes. [13]
This is where [Link] comes into the picture. As a React framework, it handles
the tooling and configurations needed for React. It introduces structure,
optimization, and new features to React applications. [Link] eliminates all the
tedious aspects of building a React app and improves the overall developer
experience. It does this by providing some key building blocks that can be used
to create web applications efficiently. [12]
For starters, [Link] does not require any configuration when setting up a new
project since everything is preconfigured. This includes automatic code
11
The major difference between [Link], and other React toolchains is how
content is rendered. [Link] offers Hybrid Static Site Generation (SSG), Server-
Side Rendering (SSR), and Client-Side Rendering (CSR). With SSG, content of
the site is generated at build time or when the project is compiled. With SSR,
the server renders the page at request time and responds to the client with the
content ready. Lastly, with CSR the content of the website is rendered in the
browser with javascript. Create React App only offers CSR by default.
3.4 Backend-as-a-Service
The most obvious advantage of using BaaS solutions is the increased speed of
development. BaaS solutions provide reusable code that can help reduce time
wasted on building repeatable tasks. Software development is costly, and time
consuming, and since most development tasks are handled manually, BaaS
provides the ability to automate time consuming tasks. This can lead to an
increased growth in productivity of software development [17].
Figure 4. The average software developer salary around the world (2021). [19]
Although BaaS can be time-effective and less costly, in certain use cases it is
not the best solution. Especially when building an application that plans to grow
fast, is expected to have a large user base, requires a unique or custom
functionality that is not provided by any BaaS or is expected to be on the market
for a prolonged period. In these cases, the preferred solution should be a
15
BaaS is a competitive market where prices can change abruptly, and the
increase in cost because of growth in traffic is not easily negotiable. Despite
platforms such as Firebase providing a no-cost plan, for high level use cases, it
is a requirement to switch to a paid-tier pricing plan. With custom backends
there is more leeway when it comes to dealing with finances. [18]
Progressive Web Apps are applications that utilize modern technologies, APIs,
and development patterns to enhance ordinary applications by providing native-
like user experience. In simple terms, PWAs do a good job integrating the best
qualities of both web and native applications. For example, web apps are easily
discoverable, sharable and can be accessed without the need for installation.
[20]
16
However, native applications also have some advantages over ordinary web
applications. For example, because native applications are built for a distinct
platform, like Android or iOS, they are well integrated with the system, and thus
are very fast and responsive. Another major advantage of native applications is
that once they are installed, they have the capability of working offline. Native
applications offer the users the ability to simply tap an icon to launch an
application, as opposed to first looking for a browser, and then searching for the
application. Ultimately, native apps have better capabilities and because they
are well integrated to the system they run on, native apps can easily utilize
mobile features such as camera, Global Positioning System (GPS), sensors,
phone call and more. Meanwhile web apps have better reach, due to search
engines, their cross-platform nature, and easy shareability. [20]
As can be seen in figure 5, with progressive web apps, users can enjoy some of
the capabilities offered by native apps while simultaneously offering the
reachability of regular web apps. The idea of PWAs is not an entirely new
17
concept but it is a concept that has been improved using different approaches.
[20]
This section presents some of the requirements needed to build a PWA, the
technologies needed, and the tools used to measure the PWA performance of
applications.
An application with a good search engine optimization (SEO) can increase its
chances of being discovered by search engines. This can help broaden the
overall reach of the application and drive-up online traffic. It also makes it easier
for search engines to categorize, rank, as well as provide metadata for
browsers to use for other use cases. [20]
Any metadata related to an application can be specified using <meta> tags inside
HTML header blocks. Similarly, a common web standard known as web app
manifests can be used to include other relevant information. The web app
manifest provides details about a web application in a JavaScript Object
Notation (JSON) formatted file. The JSON text file can contain key information,
such as display, name, icons, theme_color, and numerous more. [20]
Applications that are installable are easy for users to find and use. This added
capability can enhance the overall experience of users. Installed applications
18
Modern web applications can achieve the same experience in Chrome via in-
browser installation. This is possible if the web app has not been already
installed before and is being served over Hypertext Transfer Protocol Secure
(HTTPS). The app also needs to contain a service worker registered with a
fetch handler, and a web app manifest including name, short_name, icons,
start_url, display, and prefer_related_applications.The name, and short_name
properties define the name of the application displayed to the user. The icons
property is an array of objects containing image files used as an icon for
different contexts. For instance, to be used as a launch icon or to represent the
app amongst a list of other apps. The array must include a 192px and 512px
icon.
The start_url specifies the URL loaded when the app is launched. The display
property determines the preferred display mode for the application, and it is
recommended to be set as fullscreen, standalone or minimal-ui. Lastly, the
prefer_related_applications property is a boolean value that specifies whether
the browser should prompt an installation banner for a native app or PWA.
Therefore, this property must be set to false to allow for installation.
Chrome was selected as an example as it was the preferred option for the
project due to its availability. Other web browsers have similar conditions for
enabling in-browser installation but with minor differences. For instance, on
Opera, the minimal-ui mode is not supported, so instead it will fall back to
browser mode which uses normal browser UI. In addition, Opera does not yet
support them_color, or background_color. For Samsung Internet it is suggested to
set the display property to either standalone or fullscreen, and an icon where
the size is at least 144x144 must be included. Lastly, if Firefox for desktop is
being used then PWA installation is not supported as of 2021.
The basic idea behind network independence is to have content that can be
present on the page even when the network is unreliable or unavailable. When
19
users revisit a site or try to access content on a page that had previously been
accessed, the content is available even when the network connection is poor.
[20]
Progressive web apps can achieve this by using a few technologies. Service
Workers act as a proxy existing in a separate thread from the main browser
thread, meaning they sit between web applications, the browser, and the
network [23]. A service worker takes on the form of a JavaScript file with the
ability to intercept requests and perform certain actions based on the network
state.
Additionally, a Service Worker can update, retrieve resources from the Cache
API, and deliver push notifications [23]. The Cache API is persistent storage for
request and response object pairs and can be utilized to store site resources,
such as assets, for requests made offline [24]. In combination with offline data
storage technologies such as indexedDB and Web Storage, progressive web
apps can deliver a seamless offline experience. [20]
Building a web application that is secure can have several benefits. For
instance, the encryption layer is enabled, and data is protected from malicious
sources. Moreover, it can help build trust with web visitors, and improve web
ranking. [26]
4 Firebase
Firebase offers two types of databases that can synchronize data in realtime.
The Firebase Realtime Database is a cloud-hosted, not only structured query
language (NoSQL) database that can store data in JSON and synchronize in
real time across all users. Unlike the typical HTTP request and response model,
the Firebase database uses data synchronization. As a result, anytime data is
changed, devices that are connected receive an update within milliseconds.
21
Another key capability is its ability to work offline. The Firebase SDK preserves
data locally, which means applications built with Realtime Database remain
responsive while offline. When a device regains connection after being in offline
mode, Realtime Database can locally synchronize remote changes that
occurred while the client was in offline mode. [27]
More importantly, the database can be accessed from client devices, which
means server setup is not required. Database validation, and security rules can
be set directly from the Firebase Command Line Interface (CLI), or Firebase
Console. Unlike relational databases, the Realtime Database is a NoSQL
database that scales horizontally, handles large data sets, and executes quick
operations [28]. Moreover, It can support 200,000 concurrent connections, and
has a 1000 writes per seconds rate limit. If the specified limits are exceeded,
multiple databases can be set up. The structure of the database is JSON, and it
is formatted as a key-value pair. It is supported by Android, iOS, C++,
JavaScript, Unity, Flutter and more. [27]
Documents support various data types ranging from simple strings and numeric
values to complex data types, such as nested objects, also known as maps.
Additionally, documents can contain subcollections, which can form a
hierarchical data structure. Documents are very similar to JSON, but they
support more data types, and have a size limit of 1MB. The Cloud Firestore is
different from relational databases in that it has no schema, which means it
offers more liberty over fields or data types that are stored inside
documents. Lastly, Cloud Firestore supports simple queries, complex queries,
filtering, limitation, and sorting data. [29]
Table 1. The Differences between Cloud Firestore and Realtime Database. [30]
Realtime and Offline support only for iOS Offline support for iOS,
offline and Android clients. Android, and Web clients.
Support
between the two databases include the role of the database, data operations,
the data model, availability, offline queries, and database instances.
As far as the role of the database, the usage of the database should be known.
If the database is used for simple queries and data synchronization, then
Realtime Database is recommended. Otherwise for complex queries, then
Cloud Firestore is preferred. It is also good to know the operations that will be
made on data. For extremely large data sets that require more reads than write
operations, Cloud Firestore is favored, but for large datasets with frequent
updates, Realtime Database is suggested.
The structure of the data can also be used to determine an appropriate pick
between the two databases. If the structure is a JSON tree, then Realtime
Database is more suitable whereas if the preferred structure is as collections
containing documents, then Cloud Firestore would be more favorable. In some
cases, the uptime of the database might even be crucial. Therefore, if a critically
high uptime is of importance, then Cloud Firestore is suggested. Otherwise for
high but non-critical uptime, Realtime Database is recommended. Moreover, if
poor connectivity is of main concern, then it might be good to know the
frequency at which queries are made on devices with poor connectivity. If
frequent, Cloud Firestore is advised, and if not, then either one would be
preferable. Lastly, if the usage requires beyond the capabilities offered by a
single database, then the amount of database instances that can be created
might be important. For multiple instances, Realtime Database is preferable.
Otherwise, either one would suffice.
4.3.1 Authentication
The firebase authentication SDK also offers a way to create and manage users,
but it must be set up manually. Similar to FirebaseUI it supports authentication
with email address and password, phone number, and third-party identity
providers, such as Google, Facebook, and many more. Additionally, it provides
a way to integrate custom auth systems, as well to anonymously sign-in users
by creating temporary accounts that can be upgraded to regular accounts if
anonymous decide to sign up later. [31]
Cloud storage is a solution built for storing and serving user-generated content
such as photos, videos, audios, and documents. It is backed by Google Cloud
storage, which means user-generated content can be accessed through
Firebase or Cloud Storage. With the help of the Firebase SDKs, developers can
upload or download directly from clients. Additionally, it is also possible to
access the same content on the server with the help of Google Cloud Storage
APIs. If necessary, this gives developers the ability to perform server-side
operations such as image filtering or resizing. [32]
Moreover, the Firebase SDKs for Cloud Storage has a few key capabilities. For
instance, Cloud Storage can perform operations regardless of network quality. If
27
Developers can deploy code with Cloud Functions directly using the command
line. Once a function has been deployed, Google’s servers will instantaneously
start to manage the function. The function will fire in response to HTTP requests
or in the case of a background function, it will listen to events, and run the
function once it has been triggered. Each function runs in a separate
environment with its own configurations. If the load of an application increases
or decreases, it will quickly scale the amount of virtual server instances required
to run the function. If the function is idle, updated or deleted, instances will be
cleared up and replaced by new instances. Additionally, when there is a
deletion, any connections with the event provider are removed. [33]
4.3.4 Hosting
Firebase Hosting is a service used to deploy web applications, and can support
static or dynamic content, as well as microservices. It is built with free Secure
Sockets Layer (SSL), so the connection over which the content is served is
28
5 Supabase
Every project created in Supabase includes a full Postgres database. Since the
database is built on Postgres, it is relational. This means that data can be
organized into tables that are linked based on defined relationships. The items
inside the tables can be organized as rows and columns. Supabase offers a few
ways of creating tables. The easiest way to create a table is directly from the
dashboard using the intuitive table view provided by Supabase but it is also
possible to do so by running SQL queries. When creating a table each column
must have a predefined data type. Supabase offers default types but it is also
possible to create custom types if the ones already provided are insufficient.
Database tables are secured using Row Level Security (RLS) policies. Since
data can be accessed directly from the client using the anon key provided by
Supabase, it is important to restrict access to private tables using RLS policies.
This can be achieved by running code inside the SQL editor or via the
Supabase dashboard. The policies can be as complex as required.
Supabase also supports SQL functions that exist inside the database. A
database function can be created using SQL or from the dashboard. After a
function is created it can be executed inside the database or directly from the
client library. A database function is best suited for handling data intensive
operations.
The platform also includes other additional features, such as a realtime engine
that is extended by postgres for listening to database changes. It also offers
extensions that can be enabled to further expand the functionality of the
database. Moreover, Supabase self manages data backups, and allows data
imports from comma-separated values (CSV) or excel spreadsheet. It also auto-
30
generates self-documenting, secure, fast, and scalable APIs directly from the
database schema. [35]
Supabase also has a system for authorization which offers several ways of
authenticating users. For instance, users can be authorized with email and
password, phone number, magic links (one-click sign-in), or third-party social
providers. For the third-party authentication, Supabase offers a great deal of
providers to choose from. Third party authentication can be enabled from the
settings tab of the authentication page by providing a client ID and a secret for
the selected provider. When a user signs up, Supabase automatically creates a
user’s table with unique ids which makes user management, and authorization
easier. For authorization, RLS and Policies can be used to set complex SQL
rules. [35]
Similar to Firebase, Supabase provides space for storing and serving media
files such as images, and videos. The Supabase storage uses buckets which
serve as containers for files and folders. A bucket can be useful for separating
files based on access rules. For instance, files that are accessible by everyone
can be stored inside a public bucket and private files can be stored inside a
private bucket. Buckets can be created using the Supabase Dashboard, an
SQL editor or the Supabase client library. Figure 8 showcases a bucket created
for storing avatars using the Supabase Dashboard.
31
The images stored inside the avatar bucket, as shown in figure 8, are organized
under folders with user ids as names for easier access. To secure buckets,
operations made to files can be restricted by adding policies with different
security rules. Moreover, files can be uploaded, downloaded, sorted or deleted
directly from the dashboard. [35]
At the time of writing, in 2022, this service is new and is still in the experimental
stage, hence it is not recommended for production use. The Supabase CLI can
be used to create and deploy Edge Functions or manage environment
variables. Edge functions can be deployed locally or to production. When
deploying to production, the deploy command automatically bundles the edge
functions. Once deployed, the Functions section of the dashboard offers a
couple of debugging tools. The first debugging tool is called invocations and is
used to display requests and responses for each execution. The second
32
debugging tool logs all platform related events such as errors and
deployments.[35]
6 Implementation
For the case project, two identical applications were built using two different
backend service providers. This chapter details some of the steps taken to
create the case project. Furthermore, it aims to highlight the main distinctions in
implementation of an application using Supabase and Firebase. It describes the
functionalities of the project application and briefly mentions other technologies,
and software tools required to facilitate the creation of the product.
The goal for the case project was to create an application that would send an
email to users, including weather information for the following day. Users would
have the options to specify the location for the weather information, and how
frequently they would want to receive the message. In addition, users also can
disable the option to receive any weather updates. To make the application
tailored to individual needs, users would be required to provide personal
information by signing up.
33
Visually, the application has a sign-in form as a start-up screen as seen in the
top left of figure 9. The page has links pointing to forms for registering and
recovering passwords. If a user logs in successfully, the user is redirected to the
home page depicted in the bottom left of figure 9. For navigating to different
parts of the page, a navigation bar is included with different tabs.
The profile tab, second from the bottom left of figure 9, is used to navigate users
to the profile page where the user can see a profile image, display name, email,
and a button to modify the profile details. The settings tab is for navigating users
to a page with a side bar including two more tabs which lead to an account
settings form, and a profile settings form. With the profile settings form, located
third from the bottom left of figure 9, users can change their profile image,
34
display name, and email. Users can also use the form to delete their account or
change their password. Lastly, from the account settings form, located first from
the bottom right of figure 9, users can configure the behavior of the weather app
by setting how frequently they want to receive an update, what city they want to
receive an update for, and whether they should even receive anything at all.
The development environment for the project uses a few programming tools to
set an efficient workspace. The selected code editor for the project was VS
code 1 which is a popular work environment for building and debugging
applications. The project also requires [Link] 2 to be installed. [Link] is a
runtime environment that allows JavaScript to be run on the server. [Link] has
a package manager known as node package manager (NPM) 3, which is used
for installing libraries for the project. For styling, tailwind is installed then tailwind
directives are added in a CSS file. A [Link] file is created for
configurations and specifying files where tailwind 4 is required. ESlint 5 is also
added for code formatting and adherence to a specific style guideline.
1
[Link]
2
[Link]
3
[Link]
4
[Link]
5
[Link]
35
Figure 10 illustrates the general code structure which follows the automatic
setup provided by a NextJS project. The components folder is where the different
components used in the application are defined. The pages folder is where the
routes for the pages are defined based on the filenames. The folder also
includes an api folder where any API endpoints for the application are specified.
All static files are stored inside the public folder for NextJS to serve. The styles
folder contains a CSS file where tailwind directives are defined. Lastly, the utils
folder is where all JavaScript logic is defined.
The application utilizes forms, dropdowns, modals, a navbar, buttons, and many
more UI elements. To facilitate this, customized TailwindUI components were
used. TailwindUI is a component library that provides professionally designed
36
The components in TailwindUI are designed for tailwind CSS version 2 and 3.
Therefore the project uses tailwind version 3. TailwindUI relies on Headless UI
for its UI components, and to power the interactive behavior it offers. It also
relies on Heroicons for icons, so both libraries need to be installed before using
it. Once TailwindUI was fully integrated, the application was built with
responsive components to adjust to different screen sizes. The distinction
between the apps built with Supabase and Firebase is mainly in the business
logic, and therefore both applications have an identical appearance.
Clicking on the add project button shown in figure 11 will open a pop-up window
that asks for the project name, whether Google analytics should be enabled and
what the country of organization for the project should be. Google analytics was
disabled for this specific project since it was not necessary. After providing the
required details, the Project dashboard will be visible. To integrate Firebase into
the app, the cog wheel icon was first clicked and then the web app icon was
selected from the project settings page. Firebase will then generate the code
snippet shown in listing 2.
const firebaseConfig = {
apiKey: "123",
authDomain: "[Link]",
projectId: "app-123",
storageBucket: "[Link]",
messagingSenderId: "123",
appId: "1:123:web:123b"
};
const app = initializeApp(firebaseConfig);
Before using the firebaseConfig, the npm install firebase command is run in the
terminal inside the root project folder. Then the Firebase configuration was used
inside the project to initialize a new Firebase application as illustrated in listing
2. For the case project, the Firebase SDK was initialized as a client with
Firestore, Authentication, Storage, and a Google authentication provider.
let app
if (!getApps().length) {
app = initializeApp([Link].NEXT_PUBLIC_FIREBASE_CONFIG)
}else {
app = getApp('weather-app')
}
const db = getFirestore()
const auth = getAuth()
const storage = getStorage(app)
const provider = new GoogleAuthProvider()
[Link]({ prompt: 'select_account' })
//View your data across Google Cloud Platform services
//[Link]('[Link]
Listing 3 shows the Firebase client being initialized using the configuration
details stored as an environment variable under the key
NEXT_PUBLIC_FIREBASE_CONFIG. The app is only being initialized if an instance does
not already exist. Otherwise, the getApp(name)function is used to retrieve an
existing FirebaseApp. The set setCustomParameters function of GoogleAuthProvider
is also set to select_account. This forces account selection when signing with
Google.
account. The second mode is Redirect mode which forces a redirect to a new
page to sign-in. For this project, the Popup mode was used as demonstrated in
listing 4.
}).catch((error) => {
// Handle Errors here.
const errorMessage = handleError(error)
})
To allow users to save profile photos, Firebase Storage provides a method for
uploading files. Before uploading a file, a reference to its full path and name
needs to be created. Once a reference is created, Firebase can upload from a
file, a binary large object (blob), byte array, or string. For the case project, the
state_changed observer was used to monitor the upload progress and display a
progress bar. Lastly, to secure the images, the read and write rules depicted in
listing 5 were defined using the Firebase Security Rules.
rules_version = '2';
service [Link] {
match /b/{bucket}/o {
40
match /{userId}/profilePicture/{fileName} {
allow read: if [Link] != null;
allow write: if [Link] == userId
&& [Link]('image/.+');
}
}
}
The main functionality of the application is to be able to send weather details for
a specific city. To achieve this, data about the specified city and information on
how frequently the updates should be sent was collected and stored. Then a
scheduled function was created to retrieve the stored information and send
weather updates to users.
A form was created to gather the required details. To implement a selector for
picking cities an NPM package called react-google-autocomplete was used.
The package easily integrates google places autocomplete service with React.
After implementing the form and once the frequency, city and status fields were
filled, submitting the form would trigger a function that would validate the
selected city as shown in listing 6. The validity of the city was checked to see if
the weather API had information for the selected city. The weather API used for
the project was Visual Crossing 6.
6
[Link]
41
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
}
try {
const response = await fetch (url, options)
const data = await [Link]()
if(data?.address){
return true
}
return false
} catch (error) {
[Link]()
return false
}
}
The next step was to create two scheduled functions where one would run daily,
and the other monthly as depicted in listing 7. Firebase scheduled functions
support Unix Crontab and App Engine syntax for specifying the time. The
functions were defined, and Firestore was initialized using the admin SDK.
Inside the scheduled functions, account information was retrieved based on the
status set for the weather update. Once all the information was retrieved from
the database, it was iterated, and the email address was used to send the
weather to corresponding users. For sending email messages, Nodemailer 7
was used. Nodemailer is a [Link] module which allows sending email
messages using email credentials.
Finally, once all the functionalities were complete the app was deployed using
Firebase Hosting. To achieve this, the Firebase CLI was used first to set
Firebase configurations. Lastly, the deploy command was used to deploy the
project using Firebase CLI. When the deployment is complete, the CLI logs the
application URL. The default behavior is that Firebase generates a domain
7
[Link]
42
name based on the project name, but it is also possible to add a custom domain
name if needed.
The first step to getting started was signing in to Supabase with a GitHub
account. Once signed-in clicking the New Project green button opens a box
asking for an organization, name, database password, and region. The default
organization, and the closest region were selected. The rest of the box was
filled with the project name, and a strong database password. Finally, clicking
the Create new project button generates a new project.
Before initializing the client, a profile table was created from the Table Editor
section of the sidebar. Once a database table was created, Supabase
automatically creates an API for the client with auto generated documentation.
The client can be set up by directly copying the code from the generated
documentation.
export {supabase};
A URL service_role and anon_key is also provided from the API settings sidebar.
The service_role key is what gives full access to the data and can bypass any
security policies. Therefore, the service_role key should not be used client side.
In listing 8 the Supabase url and anon_key are passed as arguments to the
createClient(url,anon_key) function to initialize Supabase.
43
try {
const result = await createUserWithEmailAndPassword(email, password);
user = [Link]
} catch (error) {
[Link](error);
}
At the time of implementing the main functionality in May 2022, Supabse did not
have functions as a feature. Supabase Edge Functions are now supported but
the limitations faced were that it was still in the experimental stage and only
supported POST responses. Therefore, to achieve sending weather updates to
users periodically, a Postgres extension named pg_cron was installed. The
extension would run periodic jobs within a Postgres database which was exactly
what was needed for this use case. Additionally, an HTTP extension was also
enabled to allow making HTTP requests inside the database a possibility.
Listing 11. JavaScript code with plv8 extension for constructing weather data,
and message.
8
[Link]
45
Lastly, all the logic for constructing the message was defined inside the
Supabse SQL editor as illustrated in listing 11.
select
[Link](
'weather-every-month', -- name of the cron job
'0 0 1 * *', -- every month
$$
select send_weather();
$$
);
The pg_cron extension allows scheduling Postgres commands directly from the
database. The cron based scheduler uses the same syntax as a regular cron,
where the * sign means run every time period, and where a specific number
means but only at this time. The cron job illustrated in listing 12 accepts two
arguments, the name of the cron job, and how frequently it is executed. In this
case, it will run at midnight on every first day of the month.
To convert the app into a PWA, a plugin for [Link] called next-pwa 9 was
installed. After installing the required dependency, a [Link] file was
created including a maskable icon, which makes the PWA icon look good on all
android devices. The file was then stored inside the public directory along with
all the icons referenced inside it. The manifest file contained a theme_color,
background_color, scope, start_url, short_name, description, icons, and a display
set to standalone.
<Head>
<link rel="manifest" href="/[Link]" />
<link rel="apple-touch-icon" href="/[Link]" />
<meta name="theme-color" content="#fff" />
</Head>
Listing 13. The code snippet required inside the _document.js file
9
[Link]
46
As illustrated in listing 13 a _document.js file was created inside the pages folder
to reference the location of the documents manifest as well as set the icon and
theme color. The remaining steps were to configure next-pwa inside the
[Link] file as displayed in listing 14, and to include the auto generated
files by next-pwa inside the .gitignore file.
[Link] = withPWA({
reactStrictMode: true,
env: {
NEXT_PUBLIC_FIREBASE_CONFIG: [Link](
[Link].NEXT_PUBLIC_FIREBASE_CONFIG
),
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY:
[Link].NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
NEXT_PUBLIC_WEATHER_API_KEY: [Link].NEXT_PUBLIC_WEATHER_API_KEY,
},
images: {
domains: [
'[Link]',
'[Link]',
'[Link]',
'[Link]',
],
},
pwa: {
dest: 'public',
register: true,
skipWaiting: true,
},
});
As seen in listing 14, the pwa object inside the [Link] is used to
customize the behaviour of the plugin. The dest property determines where the
files generated by the plugin will be stored. In this case it is stored inside the
public directory. The register property which is set to true tells the plugin to
register a service worker. Lastly, the skipWaiting property ensures that a new
service worker is immediately activated.
47
To test whether the application was PWA, an audit was performed from the
Lighthouse panel of Chrome's DevTool. Lighthouse is a free software that can
perform inspections for accessibility, PWA, best practices, performance and
more [37]. Figure 23 shows that the application passes all the requirements for
a PWA.
7 Results
When comparing features, the results showed that Firebase is a lot more
feature rich. Firebase offers products for building, releasing, and monitoring
applications as well as engaging users to applications. For instance, Firebase
offers a performance monitoring tool which can help a developer gain some
important insight about the performance of an application. The performance tool
is capable of measuring the startup time of an application, and how long it takes
a block of code to execute.
48
Supabase currently only offers products for building software, but even then the
Supabase product catalog is not comparable to that of Firebase. In total,
Firebase offers 24 products while Supabase is mainly focused on 4 key
products. This is partly because, as of 2022, Supabase is still relatively new as
it was first launched in 2020.
With its longevity, Firebase has acquired a large community of users, and a
strong support system. Figure 24 shows a simple search result with the
Firebase tag on stackoverflow generates hundreds of thousands of questions
whereas a search result with the Supabase tag generates hundreds of
questions. The company is also backed by Google, which is one of the leading
tech companies in the world. Therefore, the services it provides are required to
meet the industry standards.
The biggest difference between Firebase and Supabase is the database they
each offer. Supabase has a Postgres database while Firebase has a NoSQL
49
The first limitation is that only one function can be run in local development. The
second limitation is that the function only supports POST responses, which
means event-based triggers or scheduled tasks are not supported. Lastly,
HTML responses are also not supported by Supabase Functions.
Firebase offers a service that handles hosting applications with either dynamic
or static content. Most importantly, it does this securely with fast delivery [34].
50
Supabase on the other hand does not have a hosting service, which means
another platform would be required for handling hosting.
Firebase offers several services that are more tailored to building PWAs. For
instance, the Firebase Hosting serves applications over HTTPS with SSL
certificates which adds safety and security. It can also cache dynamic and static
content on a global CDN which can help improve load time. Moreover, Cloud
Firestore supports offline data persistence which enables applications to fully
operate while offline.
Firebase pricing is based on two tiers. The first tier is the Spark Plan which
offers a lot of free features with a certain limitation. This tier is recommended for
small projects that do not generate a lot of traffic. The second tier is the Blaze
Plan or also known as the pay as you go plan. For this plan each individual
service is offered as free but requires payment for any usage that surpasses the
free threshold.
51
Table 2. Firebase price table for database, authentication, and storage services.
[38]
Table 2 demonstrates how large enterprise scale projects require more than the
free tier to handle increased API calls. For small scale or personal projects, the
free tier should be adequate. Firebase offers 1 GB of database storage for free
which is a lot more than the 500MB of storage Supabase offers for the same
tier. However, despite firebase offering larger database storage, it comes with
limitations for reads, writes, and deletes made. If those limits are exceeded,
then additional costs will be accrued.
The most notable difference between the free tier provided by Supabase and
Firebase is the price for storage. Supabase offers 1 GB of storage for free and
Firebase offers 5 times that. Moreover, the transfer limit offered by Supabase is
2 GB per month whereas Firebase offers a transfer limit of 1 GB per day.
Therefore, for projects that are storage intensive, Firebase Storage might be
ideal.
52
Supabase has APIs that are auto generated based on the database, and this
feature is exclusive to Supabase only. The APIs include auto-generated
documentation which updates as changes are made to the database. This
simplifies integrating Supabase to the client.
The syntax for handling errors is also simplified with Supabase, unlike Firebase
where the syntax requires try and catch blocks to handle errors. For
authentication, the developer experience offered is similar to Firebase, but
Supabase has more third-party providers to select from. Additionally, Supabase
has a great feature called Remote Procedure Call (RPC) which allows writing
some logic to the database and then calling it directly from the application. This
is useful when performing tasks where the logic does not change, such as
account deletion, and password reset. It also has the benefit of having less
client-side logic.
Lastly, Supabase offers Self Hosting where developers can deploy and
personally manage the Supabase infrastructure. This is great because it gives
developers the ability to personalize Supabase according to their needs. It also
frees developers from vendor lock-in, so developers are not entirely dependent
on the service provider, which is the case with Firebase.
The Firebase database struggles with this due to its document-based structure,
which makes deeply nested references difficult to query. Another great
database feature provided by Supabase is the ability to import directly from
CSV or excel spreadsheet. This can be useful when migrating from a different
platform. Additionally, as the database is updated, Supabse auto generates
documentations used to handle CRUD operations more efficiently.
Similar to Firebase, Supabase has a free tier but with limited amount of storage.
Additionally, Supabase offers a pro tier with a base price of 28$/month for
production level application, and an enterprise tier for enterprise level projects.
Table 3 shows that Supabase offers unlimited API calls whereas Firebase
charges for database reads and writes. If a project needs to make a lot of API
calls, Supabase might be a great option in terms of pricing.
The first performance measurement conducted was a speed test using the
Lighthouse tool built by Google. In this instance, It is important to note that
54
version 8 and 9 of the Lighthouse Scoring Calculator was used for the test. The
results acquired are estimated and vary at times so each website was analyzed
a couple of times then the average result was calculated. The average overall
performance score for the website built using Firebase was 65 out of 100, while
the average overall performance score for the website built using Supabase
was 76. The overall performance score is measured based on several metrics.
Figure 25 shows the result of all the different metrics after a single analysis of
each website.
The first metric looked at was the First Contentful Paint (FCP) metric which
marks the time the first text or image is painted on the browser. The Firebase
website had an average FCP of 1.6 seconds while the Supabase website had
an average FCP of 1.7 seconds. As a reference, Google recommends an FCP
of 0 to 18 seconds, so both websites produced a good result. The second
metric looked at was the Time To Interactive (TTI) which measures the amount
of time it takes for a page to become fully interactive. The Firebase website had
an average TTI of 4.6 seconds while the Supabase website had an average TTI
of 3.7 seconds. A TTI score in the range of 0 to 3.8 seconds is considered fast.
Overall, the results of each metric combined indicated that the Supabase
website had a faster speed performance.
Figure 25. Speed test result of applications with Supabase on the right side and
Firebase on the left side.
examined under an expected load. It determines how the software will behave
while being simultaneously accessed by a specific number of users. In this
instance, Firestore and the Supabase database were tested to examine how
many read and write operations can be made concurrently.
10
[Link]
56
The second load test was a Post request to create new documents. The thread
properties of the test included 1000 threads, a ramp-up period of 1 second and
a loop count of 1. As displayed in figure 27, the test plan resulted in an error
after 959 threads, and any subsequent request was timed out.
Similarly, a load test was also conducted with the Supabase database, but both
write and read operations had successfully passed the test. To further examine
the limits of the database, the number of threads was increased to 2000 and a
GET request was made to read the profile information of a specific user. As
seen in figure 28, the first error occurred after 1770 threads and subsequent
requests would sporadically result in failure. Lastly, a POST request was also
made with similar thread properties which resulted in failure after 1184 threads.
57
8 Conclusion
The findings from the project revealed that determining the better platform is not
as clear-cut as each platform has its own advantages and disadvantages.
Selecting the right platform between the two depends on the use case of the
project. For instance, Supabase offers a relational database which can be great
for projects that require full-text search or need to make complex queries.
Firebase on the other hand offers a hosting service as well as a NoSQL
database which can be great for storing unstructured data.
The thesis addresses the criteria initially set and provides answers to questions
asked in the research. Moreover, it describes the building process of a weather
application that was successfully implemented using Firebase and Supabase.
The work done in building the demo application had revealed which platform
was more suitable for implementing certain functionalities. For instance, it was
discovered that scheduled jobs are more difficult to implement with Supabase
since Supabase does not offer a dedicated service for handling scheduled
functions.
References
[Link]
most-used-frameworks-web. Accessed 12 May 2022.
14 Tanna, Mayur, & Harmeet Singh. 2018. Serverless Web Applications with
React and Firebase: Develop Real-Time Applications for Web and Mobile
Platforms. Packt Publishing, Limited. ProQuest Ebook Central. Electronic
Book. [Link]
ebooks/[Link]?docID=5345875. Accessed 23 May 2022.
17 Batschinski. George. 2022. BaaS: What are the benefits? Online. 9 May
2022. [Link]
a-service/. Accessed 24 Mar 2022.
19 Geerligs, R., 2021. Software Developer Salary Around the World | 2021.
Online. 17 Feb 2021. Daxx Software Development Teams.
[Link]
developer-trends. Accessed 24 Mar 2022.
[Link]
US/docs/Web/Progressive_web_apps/Introduction. Accessed 12 May
2022.
21 Richard, S. and LePage, P., 2022. What are Progressive Web Apps.
Online. 24 Feb 2020. [Link] Accessed 12 May
2022.
26 Google Developers. 2022. How to Secure Your Site with HTTPS | Google
Search Central | Documentation | Google Developers. Online. 21 Apr
2022.
[Link]
t=HTTPS%20(Hypertext%20Transfer%20Protocol%20Secure,user%27s%
20computer%20and%20the%20site.. Accessed 15 May 2022.
28 Dearmer, A., 2022. Firebase vs. MySQL: Battle of the Databases. Online.
1 Dec 2020. [Link] Accessed 23
May 2022.
36 Young, N., 2021. The Pros and Cons of Tailwind CSS | Webdesigner
Depot. Online. 24 Sep 2021. Webdesigner Depot.
[Link]
tailwind-css/. Accessed 24 May 2022.