DEV Community

loading...

Vue.js Firestore example - Vue.js CRUD serverless with Firebase Cloud Firestore

loizenai profile image loizenai ・3 min read

https://ozenero.com/vue-js-firestore-example-vue-js-crud-serverless-with-firebase-cloud-firestore

Vue.js Firestore example - Vue.js CRUD serverless with Firebase Cloud Firestore

Cloud Firestore helps us store data in the cloud. It supports offline mode so our app will work fine (write, read, listen to, and query data) whether device has internet connection or not, it automatically fetches changes from our database to Firebase Server. We can structure data in our ways to improve querying and fetching capabilities. This tutorial shows you a Vue.js app that can do Firebase Firestore CRUD Operations.

Related Post: Vue.js CRUD example – a simple Note App

Vue.js Firestore example Overview

Goal

Our Vue App can help us write new Notes, then it displays a list of Notes and each Note page (containing title and content) can be modified easily. This App also supports offline mode - we can create/update/delete Note without internet connection.

vuejs-firestore-example-crud-note-app-overview

And, of course, this App interacts with Firebase Firestore as backend infrastructure:

vuejs-firestore-example-note-app-firebase-firestore-result

Demo

Project Structure

vuejs-firestore-example-crud-note-app-project-structure

We have 3 components:

  • App.vue holds all of the other components.
  • NotesList.vue contains all of notes in a List with + Note button.
  • Note.vue display a single Note in the List that allows us to create new Note or edit current Note.

    Technologies

  • Vue CLI 3.0.1
  • Vue 2.5.17
  • Firebase SDK for Javascript 5.4.2

    Practice

    Setup Vue Project

    Install vue-cli

    For use Vue CLI anywhere, run command: npm install -g vue-cli

    Init Project

    Point cmd to the folder you want to save Project folder, run command: npm create vue-note-app

You will see 2 options, choose default:

vuejs-firestore-example-note-app-project-setup

Install Firebase SDK

Run command: npm install firebase
Once the process is done, you can see firebase in package.json:


"dependencies": {
  "firebase": "^5.4.2",
  "vue": "^2.5.17"
},

More at:

https://ozenero.com/vue-js-firestore-example-vue-js-crud-serverless-with-firebase-cloud-firestore

Discussion (0)

Forem Open with the Forem app