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.4k
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
180
WebAPI Usecase for my home
nologyance
0
470
変わりゆくAPI連携仕様との付き合い方 / Good practice of using API
nologyance
1
1k
戦略的情報収集のすゝめ
nologyance
0
710
自己学習を支えるInoreader + Notionのその後
nologyance
0
830
自己学習を支える Inoreader + Notion
nologyance
3
16k
Other Decks in Programming
See All in Programming
CSC307 Lecture 12
javiergs
PRO
0
220
OpenAI/Gemini APIを使って EPUBを翻訳するCLIツールをつくってみた
tomiyan
0
790
Google's Recipe for Scaling (Web) Security – LocoMocoSec 2024
lweichselbaum
0
170
DDDを志して3年経ったら「DDDの皮を被ったクリーンアーキテクチャ」になった話【デブサミ2024夏】
texmeijin
1
620
【Go言語】ジェネリクス
tomo1227
0
170
SDCon2024: Enabling DevOps and Team Topologies thru architecture: architecting for fast flow
cer
PRO
0
780
CSC307 Lecture 14
javiergs
PRO
0
220
TiDB Serverless ~理想のServerless DBを考える~
soso_15315
1
160
Introduction to GitOps
hwchiu
0
110
Polarsの成長: v0.14からv1.0までの変遷と今後の展望
zerebom
1
350
Terraformテスト入門
msato
0
520
さきがけから振り返るアーキテクチャ刷新 / Reflecting on the Architectural Renewal from the Vanguard
nrslib
2
770
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
93
5k
Building Adaptive Systems
keathley
34
2k
From Idea to $5000 a Month in 5 Months
shpigford
377
46k
Leading Effective Engineering Teams 2024
addyosmani
3
300
Designing Experiences People Love
moore
136
23k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
78
15k
Being A Developer After 40
akosma
72
580k
Six Lessons from altMBA
skipperchong
24
3.2k
How to train your dragon (web standard)
notwaldorf
79
5.5k
The Power of CSS Pseudo Elements
geoffreycrofte
64
5.2k
How to name files
jennybc
67
96k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
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