Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nuxt.jsとFirebaseでWebアプリケーション開発

 Nuxt.jsとFirebaseでWebアプリケーション開発

Vue Night in Fukuoka #1発表資料。
Nuxt.jsとFirebaseでWebアプリケーション開発。

2018/10/13追記。Nuxt v2とPWA対応について、Qiitaに記事を書きました。
「Nuxt v2とFirebase(CloudFirestore)でPWA対応Webアプリ開発」
https://qiita.com/_takeshi_24/items/3ee051e1db1b3e8da106

TakeshiNishi

July 12, 2018
Tweet

More Decks by TakeshiNishi

Other Decks in Programming

Transcript

  1. diffeasy. inc 2 ೑೑͏ͲΜ'JSFCBTF 7VF Թઘ ಡॻ (PMBOH 3VCZ ($1

    ϒϩοΫνΣʔϯ إೱ͍ גࣜձࣾEJ⒎FBTZ σΟϑΟʔδʔ  औక໾$50 ੢෢࢙ ʹ͚ͨ͠͠  !@UBLFTIJ@ EPDLFS /VYU
  2. diffeasy. inc 21 FirebaseϓϩδΣΫτʹ઀ଓ import firebase from 'firebase' var config

    = { apiKey: process.env.FB_API_KEY, authDomain: process.env.FB_AUTH_DOMAIN, databaseURL: process.env.FB_DATABASE_URL, projectId: process.env.FB_PROJECTID, storageBucket: process.env.FB_STORAGE_BUCKET, messagingSenderId: process.env.FB_MESSAGING_SENDER_ID } if (!firebase.apps.length) { firebase.initializeApp(config) } export default firebase
  3. diffeasy. inc 22 ϩάΠϯೝূ auth.signInWithEmailAndPassword
 (data['email'], data['password']) .then((user) => {

    // ϩάΠϯ੒ޭ commit('setUser', user)}) .catch((error) => { ɹ// Τϥʔॲཧ })
  4. diffeasy. inc 23 σʔλొ࿥ const db = firebase.database() const messagesRef

    = db.ref('messages') export const state = () => ({ messages: [], }) 
 export const actions = { addMessageRef : firebaseAction((context, data) => { messagesRef.push({uid: data.uid, text: data.text, time: 9999999999999 - Date.now()}) })
  5. diffeasy. inc 24 σʔλऔಘ const db = firebase.database() const messagesRef

    = db.ref('messages') export const state = () => ({ messages: [], }) 
 export const actions = { initMessages : firebaseAction(({ bindFirebaseRef }) => { bindFirebaseRef('messages', messagesRef.orderByChild('time')) }) }
  6. diffeasy. inc 25 ετϨʔδ΁ͷΞοϓϩʔυ const storage = firebase.storage() const storageRef

    = storage.ref() export const actions = { uploadAvatar (context, data) { var avatarRef = storageRef.child(data.name); avatarRef.put(data.file) } }
  7. ©2018 diffeasy Corporation ιʔε͸ͪ͜Β https://github.com/tkc24/firebase-simple-chat 27 2018/10/13௥ه Nuxt v2ɺPWAରԠʹ͍ͭͯQiitaʹهࣄΛ͋͛·ͨ͠ɻ
 ʮNuxt

    v2ͱFirebase(CloudFirestore)ͰPWAରԠWebΞϓ Ϧ։ൃʯ
 https://qiita.com/_takeshi_24/items/ 3ee051e1db1b3e8da106