All Projects → filrak → Vue Offline

filrak / Vue Offline

Licence: mit
Offline states and storage for Vue PWA

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Offline

Night
Weekly Go Online Meetup via Bilibili|Go 夜读|通过 bilibili 在线直播的方式分享 Go 相关的技术话题,每天大家在微信/telegram/Slack 上及时沟通交流编程技术话题。
Stars: ✭ 10,058 (+3165.58%)
Mutual labels:  online, offline
Create Vue App
Create Vue apps with no build configuration.
Stars: ✭ 304 (-1.3%)
Mutual labels:  offline, pwa
use-navigator-online
⚛️ React Hooks to detect when your browser is online/offline.
Stars: ✭ 23 (-92.53%)
Mutual labels:  online, offline
React Firebase Admin
React ⚛️ starter kit with Firebase 🔥 and Bulma for setting up an admin dashboard - Highly scalable, PWA, Serverless
Stars: ✭ 232 (-24.68%)
Mutual labels:  offline, pwa
AllSQL
AllSQL is an open-source compact browser based SQL Compiler, built using Flutter.
Stars: ✭ 16 (-94.81%)
Mutual labels:  pwa, online
Jfa Pwa Toolkit
⚡️ PWA Features to Any Website (very Fast & Easy)
Stars: ✭ 245 (-20.45%)
Mutual labels:  offline, pwa
Mono-PWA
Monobank PWA — unofficial online web client for monobank
Stars: ✭ 24 (-92.21%)
Mutual labels:  online, offline
Magicpad
MagicPad is an encryption suite for beginners. It is designed to be run standalone via the browser or executable (Electron).
Stars: ✭ 174 (-43.51%)
Mutual labels:  offline, pwa
ambianic-ui
PWA for managing Ambianic Edge devices (smart cameras).
Stars: ✭ 32 (-89.61%)
Mutual labels:  pwa, offline
wordpress
Free PWA & SPA for Wordpress & Woocommerce
Stars: ✭ 103 (-66.56%)
Mutual labels:  pwa, offline
Ember Service Worker
A pluggable approach to Service Workers for Ember.js
Stars: ✭ 227 (-26.3%)
Mutual labels:  offline, pwa
Ios Pwa Wrapper
An iOS Wrapper application to create a native iOS App from an offline-capable Progressive Web App.
Stars: ✭ 268 (-12.99%)
Mutual labels:  offline, pwa
Angularfire2 Offline
🔌 A simple wrapper for AngularFire2 to read and write to Firebase while offline, even after a complete refresh.
Stars: ✭ 209 (-32.14%)
Mutual labels:  offline, pwa
Data Collection Dotnet
Data collection application built using the .NET Runtime SDK.
Stars: ✭ 17 (-94.48%)
Mutual labels:  online, offline
Pwa Qr Code Scanner
Lightweight progressive web app for scanning QR codes offline
Stars: ✭ 188 (-38.96%)
Mutual labels:  offline, pwa
ngx-online-status
🔛 Angular 5+ Detect online/offline state
Stars: ✭ 23 (-92.53%)
Mutual labels:  online, offline
Bento Starter
🍱 Full-Stack solution to quickly build PWA applications with Vue.js and Firebase
Stars: ✭ 1,519 (+393.18%)
Mutual labels:  offline, pwa
Notes
Offline-first notepad PWA
Stars: ✭ 163 (-47.08%)
Mutual labels:  offline, pwa
File-Explorer
A File Manager with stunning design & astonishing develops, beautifully written in PHP, everything fused in a single file.
Stars: ✭ 31 (-89.94%)
Mutual labels:  online, offline
Android Pwa Wrapper
Android Wrapper to create native Android Apps from offline-capable Progressive Web Apps
Stars: ✭ 265 (-13.96%)
Mutual labels:  offline, pwa

Vue Offline

This library allows you to enhance offline capabilities of your Vue.js application. It's especially useful when you're building offline-first Progressive Web Apps or just want to inform your users that they lost internet connection.

TL;DR Adds isOnline isOffline data properties, online, offline events via global mixin and enables offline storage via Vue.$offlineStorage based on Local Storage

Initially made for Vue Storefront

Installation

To install this package as a plugin just type:

npm install vue-offline --save

and add it into your application with

import VueOffline from 'vue-offline'

Vue.use(VueOffline)

Capabilities

This plugin contains two features:

VueOfflineMixin

Global mixin that'll add following properties to every component in your application:

  • isOnline & isOffline data properties
<template>
    <p v-if="isOnline">This part will be visible only if user is online</p>
    <p v-if="isOffline">This part will be visible only if user is offline</p>
</template>
export default {
    name: 'MyComponent',
    computed: {
        networkStatus () {
            return this.isOnline ? 'My network is fine' : 'I am offline'
        }
    }
}
  • online and offline events in every component
export default {
    name: 'MyComponent',
    mounted () {
        this.$on('offline', () => {
            alert('You are offline! The website will not work')
        })
    }
}

Additional configuration

By default VueOfflineMixin is injected into every component which may be a cause of potential performance problems. You can disable this behavior by setting plugin option mixin to false.

Vue.use(VueOffline, {
    mixin: false
})

You can still make use of VueOfflineMixin by injecting it directly into your components:

import { VueOfflineMixin } from 'vue-offline'

export default {
    name: 'MyComponent',
    mixins: [VueOfflineMixin],
    computed: {
        networkStatus () {
            return this.isOnline ? 'My network is fine' : 'I am offline'
        }
    },
    mounted () {
        this.$on('offline', () => {
            alert('You are offline! The website will not work')
        })
    }
}

VueOfflineStorage

Offline storage that uses local storage to persist data for offline usage and caching. It's a perfect choice for offline-first PWA. You can use it as a fallback for failed network requests or a local cache.

The storage object has following properties:

  • set(key, value) - puts (or updates if already exists) value into storage under key key.
  • get(key) - returns value stored under key key
  • keys - return array of keys existing in your offline storage

To use this storage inside your app you can either

  • use this.$offlineStorage from Vue instance property in your components:
export default {
    methods: {
        getUserData () {
            if (this.isOnline) {
                // make network request that returns 'userData' object
                this.appData = userData
                this.$offlineStorage.set('user', userData)
            } else {
                this.appData = this.$offlineStorage.get('user')
            }
        }
    }
}
  • import the VueOfflineStorage instance if you want to use it somewhere else (e.g. Vuex store)
import { VueOfflineStorage } from 'vue-offline'

const cachedData = VueOfflineStorage.get('cached-data')

Additional configuration

By default VueofflineStorage reference is included into every Vue component. You can disable this behavior by setting plugin option storage to false.

Vue.use(VueOffline, {
    storage: false
})

You can still make use of VueOfflineStorage by importing it directly into your components:

import { VueOfflineStorage } from 'vue-offline'

export default {
    name: 'MyComponent',
    methods: {
        getUserData () {
            if (this.isOnline) {
                // make network request that returns 'userData' object
                this.appData = userData
                VueOfflineStorage.set('user', userData)
            } else {
                this.appData = VueOfflineStorage.get('user')
            }
        }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].