Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PWA導入を楽にするFirebase
Search
Daiki Takaya
April 17, 2018
Programming
0
2k
PWA導入を楽にするFirebase
Daiki Takaya
April 17, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
230
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
110
Catch Up: Go Style Guide Update
andpad
0
230
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
120
私達はmodernize packageに夢を見るか feat. go/analysis, go/ast / Go Conference 2025
kaorumuta
2
590
その面倒な作業、「Dart」にやらせませんか? Flutter開発者のための業務効率化
yordgenome03
1
130
タスクの特性や不確実性に応じた最適な作業スタイルの選択(ペアプロ・モブプロ・ソロプロ)と実践 / Optimal Work Style Selection: Pair, Mob, or Solo Programming.
honyanya
3
180
Server Side Kotlin Meetup vol.16: 内部動作を理解して ハイパフォーマンスなサーバサイド Kotlin アプリケーションを書こう
ternbusty
3
210
CSC509 Lecture 03
javiergs
PRO
0
340
CSC305 Lecture 04
javiergs
PRO
0
270
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
160
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
150
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
54
11k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.7k
Six Lessons from altMBA
skipperchong
29
4k
Designing for humans not robots
tammielis
254
26k
How GitHub (no longer) Works
holman
315
140k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Navigating Team Friction
lara
190
15k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Being A Developer After 40
akosma
91
590k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Transcript
PWA導入を楽にする Firebase 株式会社ソニックガーデン 高谷大樹
自己紹介 高谷大樹(たかやだいき) 埼玉在住 24歳 2018年新卒でソニックガーデンに入社 夢: 「 おじいさんになってもお酒とプログラミングは現役で いること」
普段の活動 まかない食堂
Firebaseって? 1. サーバーレス => googleさんのサーバーと fastlyのCDN 2. クライアントだけでデータの永続化 3. 超簡単なデプロイ作業
今までのweb
Firebase デプロイ! googleサーバ Fastly製
Firebaseはなにが 嬉しいのか?
全部セットアップされてるぜ WEBサーバー, APPサーバーを入れなくても大 丈夫! nginx, unicorn, MySQLなにそれ? うまいの?から始められる。
基本は無料 PWAを試すぐらいには十分! 外部APIを叩く, データのバックアップなどしな ければ、無料で利用できる。
セットアップ方法 1. まずは登録 2. CDNで読み込み 3. Firebase Toolsをnpmでインストール
None
None
None
<script src="https://www.gstatic.com/firebasejs/4.10.1/firebase.js"></script> <script> const config = { apiKey: "<API_KEY>", authDomain:
"<PROJECT_ID>.firebaseapp.com", databaseURL: "https://<DATABASE_NAME>.firebaseio.com", storageBucket: "<BUCKET>.appspot.com", messagingSenderId: "<SENDER_ID>", }; firebase.initializeApp(config); </script>
辛いサーバーセットアップからの 解放
{ "hosting": { "public": "dist", "rewrites": [ { "source": "**",
"destination": "/index.html" } ] } } firebase.json
Vue CLIしてプロジェクトの雛形作成 https://qiita.com/567000/items/dde495d6a8ad1c2 5fa43 $ npm install -g vue-cli $
vue init webpack my-project
1. npm install -g firebase-tools 2. $ cd ~/my-project(作業dir) 3.
$ firebase init 4. $ firebase deploy
どうやってデータ保存? Cloud Fire Store Real Time Database
データの追加方法 var admin = require("firebase-admin"); var db = admin.database(); var
usersRef = db.ref.child("users"); usersRef.set({ { name: “高谷”, age: 24, email: “
[email protected]
” });
データのCRUD 1. set(データ作成, すでにデータがあると上 書き) 2. update(そのまま) 3. add(JSONツリーにデータを追加) 4.
transaction(そのまま)
どれもkey value形式
正規化は捨てよう!(1) データはフラットに! 深いネストは悪
正規化は捨てよう!(2) { "chats": { "room01": { "title": "チャットルーム01", "messages": {
"message01": { "sender": "Fumihiko Shiroyama", "message": "こんにちは。誰かいますか? " }, "message02": { ... }, "message03": { ... } } }, "room02": { ... } } }
正規化は捨てよう!(3) { "users": { "shiroyama": { "name": "Fumihiko Shiroyama" },
}, "rooms": { "room01": {} }, "room02": { ... } }, "messages": { "room01": { "message01": { "sender": "shiroyama", "message": "こんにちは。誰かいますか?" }, } }
まとめ 1. サーバー管理からの解放 2. CDNで簡単な導入 3. 無料
ご静聴ありがとうございました。