firebase-shorten-url
firebase-shorten-url copied to clipboard
Shorten URL using Firebase Dynamic Link API
Firebase Shorten URL
This is a demonstrate how to use the Firebase Dynamic Link API to build the shorten URL app.
Target:
- Simple
- Fast
- Fast 😎
Live: https://s.duyet.net


Locally development
-
Set up Node.js and the Firebase CLI
yarn global add firebase-toolsTo initialize project: Run
firebase loginto log in via the browser and authenticate the firebase tool. -
Setup packages
cd functions/ && yarn cd hosting/ && yarn -
Go to https://console.firebase.google.com and create new project.
-
Setup env variables, copy and modify
env.default.shtoenv.local.shGet the
api_keyby Project settings > General > Web API KeyGet the
domain_uri_prefixby Dynamic Links, then Add URL prefixfirebase functions:config:set config.api_key=AIzaSyC8mZm********** firebase functions:config:set config.domain_uri_prefix=duyet.page.linkRun:
bash ./env.local.sh -
Update the frontend config:
hosting/gatsby-config.js:
module.exports = {
siteMetadata: {
title: 'duyet shorten url',
description: 'Shorten URL by Firebase Dynamic Link',
author: '@duyet',
},
...
-
Running in local: https://firebase.google.com/docs/functions/local-emulator
- Export local configs:
firebase functions:config:get > functions/.runtimeconfig.json - Start firebase function:
firebase serve - Start hosting local in another terminal:
cd hosting && yarn develop - Open the UI in browser: http://localhost:8000
- Export local configs:
Deploy
Deploy serverless functions and hosting to Firebase
firebase deploy
Licence
MIT