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
Nuxt.js + firebaseでハマったこと
Search
Logy
August 26, 2020
Programming
0
7.8k
Nuxt.js + firebaseでハマったこと
フロントエンドLT会 vol.1 -2020夏祭り-
Logy
August 26, 2020
Tweet
Share
More Decks by Logy
See All by Logy
サービス開発を前に進めるために 新米リードエンジニアが 取り組んだこと / Steps Taken by a Novice Lead Engineer to Advance Service Development
nologyance
0
430
WebAPI Usecase for my home
nologyance
0
570
変わりゆくAPI連携仕様との付き合い方 / Good practice of using API
nologyance
1
1.2k
戦略的情報収集のすゝめ
nologyance
0
760
自己学習を支えるInoreader + Notionのその後
nologyance
0
960
自己学習を支える Inoreader + Notion
nologyance
3
17k
Other Decks in Programming
See All in Programming
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
6
1.5k
Носок на сок
bo0om
0
1.2k
Flutterでllama.cppをつかってローカルLLMを試してみた
sakuraidayo
0
130
The New Developer Workflow: How AI Transforms Ideas into Code
danielsogl
0
110
M5UnitUnified 最新動向 2025/05
gob
0
130
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
380
AI時代の開発者評価について
ayumuu
0
230
Golangci-lint v2爆誕: 君たちはどうすべきか
logica0419
1
230
Lambda(Python)の リファクタリングが好きなんです
komakichi
4
250
ぽちぽち選択するだけでOSSを読めるVSCode拡張機能
ymbigo
12
5.1k
Serving TUIs over SSH with Go
caarlos0
0
600
20250426 GDGoC 合同新歓 - GDGoC のススメ
getty708
0
110
Featured
See All Featured
Building an army of robots
kneath
305
45k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.4k
Rails Girls Zürich Keynote
gr2m
94
13k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
780
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
830
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Producing Creativity
orderedlist
PRO
344
40k
Transcript
Nuxt.js+firebaseͰϋϚͬͨ ͜ͱ ϑϩϯτΤϯυLTձ vol.1 -2020ՆࡇΓ- ଠా
ࣗݾհ • ଠా • גࣜձࣾϥΫε • HRTechྖҬͷ։ൃ • Nuxt.js,Firebaseॳ৺ऀ,ॳLT 2
࣍ • Nuxt.js+firebaseΛ৮Ζ͏ͱࢥ͖͔͚ͬͨͬ • ϋϚͬͨ͜ͱᶃ currentUserೖͬͯͳ͍ • ϋϚͬͨ͜ͱᶄ ίϯιʔϧΤϥʔࠈ •
͓ΘΓʹ 3
Nuxt.js+firebaseΛ৮Ζ͏ͱࢥͬͨ ͖͔͚ͬ 4
Nuxt.js+firebaseΛ৮Ζ͏ͱࢥ͖͔͚ͬͨͬ • ϑϩϯτΤϯυྗͷఈ্͛ • ؆୯ͳTODOΞϓϦΛ࡞Δ • όοΫΤϯυۃྗؾʹͨ͘͠ͳ͍͚Ͳɺೝূػೳ͘Β͍࡞Γ͍ͨ - FirebaseΛ͑ͤʹͳΕΔͱ͍͏ᷚΛࣖʹ͢Δ 5
Firebase
ϋϚͬͨ͜ͱᶃ currentUserೖͬͯͳ͍ 7
currentUserೖͬͯͳ͍ • Γ͔ͨͬͨ͜ͱ - ϢʔβʔͷϩάΠϯঢ়ଶΛνΣοΫ͔ͨͬͨ͠ - firebase.auth().currentUserΛ͑ྑ͍Β͍͠ • ެࣜυΩϡϝϯτ௨Γʹ࣮ͯ͠ϩάΠϯͯ͠Έͯɺͳ͔ͥ firebase.auth().currentUser͕͍ͭnullͰฦͬͯ͘Δ
8
currentUserೖͬͯͳ͍ • ಉ͡ηΫγϣϯͷ͙͢Լʹҙॻ͖Λൃݟ - authΦϒδΣΫτͷॳظԽ͕ऴΘ͍ͬͯͳ͍ͱnull͕ฦͬͯ͘Δ • ΘΓʹobserverʢonAuthStateChangedϝιουʣΛ͏͜ͱͰղܾ 9
currentUserೖͬͯͳ͍ • ڭ܇ - ެࣜυΩϡϝϯτͪΌΜͱಡΈ·͠ΐ͏ 10
ϋϚͬͨ͜ͱᶄ ίϯιʔϧΤϥʔࠈ 11
ίϯιʔϧΤϥʔࠈ • Γ͔ͨͬͨ͜ͱ - firebase authenticationͰϩάΠϯ͍ͯ͠ΔϢʔβʔใΛvuexͰอଘ͔ͨͬͨ͠ - onAuthStateChangedͷίʔϧόοΫͰऔಘͰ͖ΔUserΦϒδΣΫτΛ͑ྑ ͍Β͍͠ -
औಘͨ͠UserΦϒδΣΫτΛͦͷ··vuexʹ֨ೲ 12
ίϯιʔϧΤϥʔࠈ • Chrome͕ݻ·Δ͍Ͱ૿͑ଓ͚ΔΤϥʔ… - Error: [vuex] Do not mutate vuex
store state outside mutation handlers. • mutationϝιουܦ༝Ͱ͔͠࿔ͬͯͳ͍ͣͳͷʹͳͥ…ʁ 13
ίϯιʔϧΤϥʔࠈ • ಉ͡ࣄʹ͍ͭͯॻ͔Εͨͱ͋ΔهࣄΛൃݟ - Firebase AuthenticationͱVuexͷ߹ΘٕͤόάͰϋϚͬͨ • UserΦϒδΣΫτʹϦεφʔΒ͕ੜ͍͑ͯͯɺݟ͑ͳ͍ͱ͜Ζ͔Β มߋ͕Ճ͑ΒΕ͍ͯΔՄೳੑେ •
Α͘Α͘ݟΔͱΤϥʔϝοηʔδfirebaseଆͷιʔε ʮauth.esm.jsʙʯ͔Βग़ྗ͞Ε͍ͯΔ༷ࢠ 14
ίϯιʔϧΤϥʔࠈ • هࣄʹॻ͔Ε͍ͯͨΑ͏ʹɺҰผͷมʹ֨ೲͯͦͪ͠ΒΛӬଓԽ ͢ΔΑ͏ʹ͢Δͱແࣄղܾ • ͦͦUserΦϒδΣΫτશମΛӬଓԽ͢Δඞཁͳ͍ͷͰɺඞཁͳ ͚ͩ٧Ίସ͑Δͷ͕ྑ͛͞ 15
ίϯιʔϧΤϥʔࠈ • ڭ܇ - ΤϥʔϝοηʔδͪΌΜͱಡΈ·͠ΐ͏ 16
͓ΘΓʹ 17
͓ΘΓʹ • ׳Εͳ͍ٕज़Ͱ͋ͬͯجຊʹཱͪฦΔʢެࣜυΩϡϝϯτΛಡΉɺ ΤϥʔϝοηʔδΛಡΉʣ͜ͱ͕τϥϒϧղফͷۙಓ • ଟগϋϚͬͨͷͷɺೝূػೳ͙͢ʹ࣮Ͱ͖ͨ - Nuxt.js + firebase࠷ߴʂ
18
ࢀߟ • kuntalog.hatenablog.jp/entry/2019/01/07/Firebase_Authentication ͱVuexͷ߹ΘٕͤόάͰϋϚͬͨ 19