Stale-while-revalidate data fetching for Vue

Related tags

Vue.js vue swr
Overview

swrv

build

swrv (pronounced "swerve") is a library using the @vue/composition-api for remote data fetching. It is largely a port of swr.

The name “SWR” is derived from stale-while-revalidate, a cache invalidation strategy popularized by HTTP RFC 5861. SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again.

Features:

  • Transport and protocol agnostic data fetching
  • Fast page navigation
  • Revalidation on focus
  • Interval polling
  • Request deduplication
  • TypeScript ready
  • Minimal API
  • stale-if-error
  • Customizable cache implementation
  • Error Retry
  • SSR support
  • Vue 3 Support

With swrv, components will get a stream of data updates constantly and automatically. Thus, the UI will be always fast and reactive.

Table of Contents

Installation

yarn add swrv

If you want to try out Vue 3 support (beta), install the beta release and check out the Vite example. swrv code for Vue 3.0 exists on next branch.

yarn add swrv@beta

Getting Started

<template>
  <div>
    <div v-if="error">failed to load</div>
    <div v-if="!data">loading...</div>
    <div v-else>hello {{ data.name }}</div>
  </div>
</template>

<script>
import useSWRV from 'swrv'

export default {
  name: 'Profile',

  setup() {
    const { data, error } = useSWRV('/api/user', fetcher)

    return {
      data,
      error,
    }
  },
}
</script>

In this example, useSWRV accepts a key and a fetcher function. key is a unique identifier of the request, normally the URL of the API. And the fetcher accepts key as its parameter and returns the data asynchronously.

useSWRV also returns 2 values: data and error. When the request (fetcher) is not yet finished, data will be undefined. And when we get a response, it sets data and error based on the result of fetcher and rerenders the component. This is because data and error are Vue Refs, and their values will be set by the fetcher response.

Note that fetcher can be any asynchronous function, so you can use your favorite data-fetching library to handle that part. If ommitted, swrv uses the Fetch api.

Api

const { data, error, isValidating, mutate } = useSWRV(key, fetcher, options)

Parameters

Param Required Description
key yes a unique key string for the request (or a watcher function / null) (advanced usage)
fetcher a Promise returning function to fetch your data
options an object of configuration options

Return Values

  • data: data for the given key resolved by fetcher (or undefined if not loaded)
  • error: error thrown by fetcher (or undefined)
  • isValidating: if there's a request or revalidation loading
  • mutate: function to trigger the validation manually

Config options

See Config Defaults

  • refreshInterval = 0 - polling interval in milliseconds. 0 means this is disabled.
  • dedupingInterval = 2000 - dedupe requests with the same key in this time span
  • ttl = 0 - time to live of response data in cache. 0 mean it stays around forever.
  • shouldRetryOnError = true - retry when fetcher has an error
  • errorRetryInterval = 5000 - error retry interval
  • errorRetryCount: 5 - max error retry count
  • revalidateOnFocus = true - auto revalidate when window gets focused
  • revalidateDebounce = 0 - debounce in milliseconds for revalidation. Useful for when a component is serving from the cache immediately, but then un-mounts soon thereafter (e.g. a user clicking "next" in pagination quickly) to avoid unnecessary fetches.
  • cache - caching instance to store response data in. See src/lib/cache, and Cache below.

Prefetching

Prefetching can be useful for when you anticipate user actions, like hovering over a link. SWRV exposes the mutate function so that results can be stored in the SWRV cache at a predetermined time.

import { mutate } from 'swrv'

function prefetch() {
  mutate(
    '/api/data',
    fetch('/api/data').then((res) => res.json())
  )
  // the second parameter is a Promise
  // SWRV will use the result when it resolves
}

Dependent Fetching

swrv also allows you to fetch data that depends on other data. It ensures the maximum possible parallelism (avoiding waterfalls), as well as serial fetching when a piece of dynamic data is required for the next data fetch to happen.

<template>
  <p v-if="!projects">loading...</p>
  <p v-else>You have {{ projects.length }} projects</p>
</template>

<script>
import { ref } from '@vue/composition-api'
import useSWRV from 'swrv'

export default {
  name: 'Profile',

  setup() {
    const { data: user } = useSWRV('/api/user', fetch)
    const { data: projects } = useSWRV(() => user.value.id && '/api/projects?uid=' + user.value.id, fetch)
    // if the return value of the cache key function is falsy, the fetcher
    // will not trigger, but since `user` is inside the cache key function,
    // it is being watched so when it is available, then the projects will
    // be fetched.

    return {
      user,
      projects
    }
  },
}
</script>

Stale-if-error

One of the benefits of a stale content caching strategy is that the cache can be served when requests fail.swrv uses a stale-if-error strategy and will maintain data in the cache even if a useSWRV fetch returns an error.

<template>
  <div v-if="error">failed to load</div>
  <div v-if="data === undefined && !error">loading...</div>
  <p v-if="data">
    hello {{ data.name }} of {{ data.birthplace }}. This content will continue
    to appear even if future requests to {{ endpoint }} fail!
  </p>
</template>

<script>
import { ref } from '@vue/composition-api'
import useSWRV from 'swrv'

export default {
  name: 'Profile',

  setup() {
    const endpoint = ref('/api/user/Geralt')
    const { data, error } = useSWRV(endpoint.value, fetch)

    return {
      endpoint,
      data,
      error,
    }
  },
}
</script>

State Management

useSwrvState

Sometimes you might want to know the exact state where swrv is during stale-while-revalidate lifecyle. This is helpful when representing the UI as a function of state. Here is one way to detect state using a user-land composable useSwrvState function:

import { ref, watchEffect } from '@vue/composition-api'

const STATES = {
  VALIDATING: 'VALIDATING',
  PENDING: 'PENDING',
  SUCCESS: 'SUCCESS',
  ERROR: 'ERROR',
  STALE_IF_ERROR: 'STALE_IF_ERROR',
}

export default function(data, error, isValidating) {
  const state = ref('idle')
  watchEffect(() => {
    if (data.value && isValidating.value) {
      state.value = STATES.VALIDATING
      return
    }
    if (data.value && error.value) {
      state.value = STATES.STALE_IF_ERROR
      return
    }
    if (data.value === undefined && !error.value) {
      state.value = STATES.PENDING
      return
    }
    if (data.value && !error.value) {
      state.value = STATES.SUCCESS
      return
    }
    if (data.value === undefined && error) {
      state.value = STATES.ERROR
      return
    }
  })

  return {
    state,
    STATES,
  }
}

And then in your template you can use it like so:

<template>
  <div>
    <div v-if="[STATES.ERROR, STATES.STALE_IF_ERROR].includes(state)">
      {{ error }}
    </div>
    <div v-if="[STATES.PENDING].includes(state)">Loading...</div>
    <div v-if="[STATES.VALIDATING].includes(state)">
      <!-- serve stale content without "loading" -->
    </div>
    <div
      v-if="
        [STATES.SUCCESS, STATES.VALIDATING, STATES.STALE_IF_ERROR].includes(
          state
        )
      "
    >
      {{ data }}
    </div>
  </div>
</template>

<script>
import { computed } from '@vue/composition-api'
import useSwrvState from '@/composables/useSwrvState'
import useSWRV from 'swrv'

export default {
  name: 'Repo',
  setup(props, { root }) {
    const page = computed(() => root.$route.params.id)
    const { data, error, isValidating } = useSWRV(
      () => `/api/${root.$route.params.id}`,
      fetcher
    )
    const { state, STATES } = useSwrvState(data, error, isValidating)

    return {
      state,
      STATES,
      data,
      error,
      page,
      isValidating,
    }
  },
}
</script>

Vuex

Most of the features of swrv handle the complex logic / ceremony that you'd have to implement yourself inside a vuex store. All swrv instances use the same global cache, so if you are using swrv alongside vuex, you can use global watchers on resolved swrv returned refs. It is encouraged to wrap useSWRV in a custom composable function so that you can do application level side effects if desired (e.g. dispatch a vuex action when data changes to log events or perform some logic).

Cache

By default, a custom cache implementation is used to store fetcher response data cache, in-flight promise cache, and ref cache. Response data cache can be customized via the config.cache property. Built in cache adapters:

localStorage

A common usage case to have a better offline experience is to read from localStorage. Checkout the PWA example for more inspiration.

import useSWRV from 'swrv'
import LocalStorageCache from 'swrv/dist/cache/adapters/localStorage'

function useTodos () {
  const { data, error } = useSWRV('/todos', undefined, {
    cache: new LocalStorageCache(),
    shouldRetryOnError: false
  })

  return {
    data,
    error
  }
}

Serve from cache only

To only retrieve a swrv cache response without revalidating, you can omit the fetcher function from the useSWRV call. This can be useful when there is some higher level swrv composable that is always sending data to other instances, so you can assume that fetcher-less composables will have data available.

// Component A
const { data } = useSWRV('/api/config', fetcher)

// Component B, only retrieve from cache
const { data } = useSWRV('/api/config')

Error Handling

Since error is returned as a Vue Ref, you can use watchers to handle any onError callback functionality. Check out the test.

export default {
  setup() {
    const { data, error } = useSWRV(key, fetch)

    function handleError(error) {
      console.error(error && error.message)
    }

    watch(error, handleError)

    return {
      data,
      error,
    }
  },
}

FAQ

How is swrv different from the swr react library

Vue and Reactivity

The swrv library is meant to be used with the @vue/composition-api (and eventually Vue 3) library so it utilizes Vue's reactivity system to track dependencies and returns vue Ref's as it's return values. This allows you to watch data or build your own computed props. For example, the key function is implemented as Vue watcher, so any changes to the dependencies in this function will trigger a revalidation in swrv.

Features

Features were built as needed for swrv, and while the initial development of swrv was mostly a port of swr, the feature sets are not 1-1, and are subject to diverge as they already have.

Why does swrv make so many requests

The idea behind stale-while-revalidate is that you always get fresh data eventually. You can disable some of the eager fetching such as config.revalidateOnFocus, but it is preferred to serve a fast response from cache while also revalidating so users are always getting the most up to date data.

How can I refetch swrv data to update it

Swrv fetcher functions can be triggered on-demand by using the revalidate return value. This is useful when there is some event that needs to trigger a revalidation such a PATCH request that updates the initial GET request response data.

Contributors

Thanks goes to these wonderful people (emoji key):


Darren Jennings

💻 📖

Sébastien Chopin

💻 🤔

Fernando Machuca

🎨

ZEIT

🤔

Jason Yang/楊朝傑

🐛 💻

Axel Hernández Ferrera

🐛 💻 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

Comments
  • Is loading

    Is loading

    PR for https://github.com/Kong/swrv/issues/208

    Comments:

    1. Some cases of setting isLoading = false are not covered by tests. I haven't found any test cases that would cover that for isValidating which I could extend. These are is a separate (second) commit.
    2. If this gets merged, SWRV docs site would need to be updated too.
    opened by ivos 10
  • SWRV returns wrong cached data before first fetch while using key watcher function.

    SWRV returns wrong cached data before first fetch while using key watcher function.

    CodeSandbox: https://codesandbox.io/s/swrv-first-fetch-key-ip6ox?file=/src/App.vue Click on the add button and see that check turns false.

    I'd assume that the data returned by useSWRV is either undefined (no cache and data not yet available), or some cached data for that key (That is, check to be always true). Not some cached data for some older value of the key.

    opened by peter50216 10
  • Incompatibility with Vue 2.7

    Incompatibility with Vue 2.7

    Due to the direct requirements of @vue/composition-api, the package is not compatible with Vue 2. Instead, dependency tree building fails when attempting to install.

    How to reproduce

    1. Init an empty npm project
    2. npm i vue@^2.7
    3. npm i swrv
    4. Result:
    npm ERR! Found: [email protected]
    npm ERR! node_modules/vue
    npm ERR!   vue@"^2.7.8" from the root project
    npm ERR! 
    npm ERR! Could not resolve dependency:
    npm ERR! peer vue@">= 2.5 < 2.7" from @vue/[email protected]
    npm ERR! node_modules/@vue/composition-api
    npm ERR!   peer @vue/composition-api@"^0.5.0 || ^1.0.0-beta.17 || ^1.0.0-rc.5" from [email protected]
    npm ERR!   node_modules/swrv
    npm ERR!     swrv@"^0.9.6" from the root project
    
    opened by ZeroThe2nd 9
  • Allow array as key, multiple arguments to fetcher

    Allow array as key, multiple arguments to fetcher

    In the parameter documentation, the readme mentions that it is possible to pass an array as a cache key to useSWRV, presumably to allow passing multiple arguments to the fetch function as SWR does.

    Currently, this does not work and it brakes the caching completely.

    Is there a plan to support this feature, or is there another way to pass multiple arguments to the fetcher function?

    enhancement help wanted swr 
    opened by hdahlheim 9
  • refreshInterval is being swallowed by clearTimeout

    refreshInterval is being swallowed by clearTimeout

    refreshInterval seems to be cancelled immediately by https://github.com/Kong/swrv/blob/415f8eb0d6a4dd85cf34c76997308448669c9514/src/use-swrv.ts#L380

    Investigate and write tests for refreshInterval working as expected.

    bug 
    opened by darrenjennings 8
  • The behavior is unexpected when TTL value was set to 0

    The behavior is unexpected when TTL value was set to 0

    https://github.com/Kong/swrv/blob/master/src/use-swrv.ts#L45

    Sometimes we prefetch data when starting app.

    mutate('/api/appConfig', fetcher);
    

    and then use that data until use close window.

    const { data } = useSWRV('/api/appConfig');
    

    Because of the ttl, that data can be only kept 5 minutes. That forced us need to do something like below.

    mutate('/api/appConfig', fetcher, undefined, 1000 * 60 * 60 * 24 * 365);
    const { data } = useSWRV('/api/appConfig', undefined, { ttl: 1000 * 60 * 60 * 24 * 365 });
    

    I've looked the source codes. I know if the ttl is 0 means keeping the data and the refs forever. So, could you please let the default ttl be 0?

    bug help wanted 
    opened by NeoLSN 7
  • Stop revalidation on router change

    Stop revalidation on router change

    When I enabled refreshInterval=7000, every time i navigated to another page, the refetching still keep going, when i navigate to many page, my calls are build up in the background... so my current fix is to use onBeforeRouteLeave and un-render swrv component, is there any way that i can change config dynamically so that i can set refreshInterval = 0 when user navigate to other page?

    opened by vortechron 6
  • Typescript issue with @vue/composition-api > beta.6

    Typescript issue with @vue/composition-api > beta.6

    After upgrading composition api, I'm getting the following issue:

    <template>
    <div v-if="data">
       {{data.foo}} <!-- Property 'foo' does not exist on type 'Ref<{ foo: string; } | undefined> -->
    </template>
    

    I traced it down to the definition of IResponse

    interface IResponse {
        data?: Ref......
    }
    

    removing the ? makes it work again.

    it most likely has to do with https://github.com/vuejs/vue-next/pull/1682 which was implemented in beta.7

    I couldn't see that any of the examples given fit this one, but perhaps this is another breaking example

    enhancement 
    opened by blocka 6
  • feat(ssr) add ssr support

    feat(ssr) add ssr support

    • supports vue native ssr and specific nuxt context

    Credit goes to @Atinux for this one as he provided the code and helped iterate with me. Thank you!

    Sadly, the test did not work as expected, since window is currently always defined when calling renderToString... 🤔

    opened by darrenjennings 6
  • How to destructure returned data?

    How to destructure returned data?

    I am using a custom fetcher, but I am having trouble destructuring. This works:

    setup() {
      const { data } = useSWRV('/api/user', () => { ... }
      return { data }
    }
    

    This does not (omitting setup()):

    const { data: { virtualExpos } } = useSWRV('/api/user', () => { ... }
    return { virtualExpos } 
    

    This gives me "toRefs() expects a reactive object but received a plain one"

    const { data: { virtualExpos } } = useSWRV('/api/user', () => { ... }
    const { virtualExpos } = toRefs(data)
    return { virtualExpos }
    

    Strangely enough, using this simple example:

    setup() {
      const { data } = useSWRV("https://cat-fact.herokuapp.com/facts")
      console.log("isReactive(data)", isReactive(data))
      return { data }
    }
    

    Prints isReactive(data) false...

    Even though it is clearly reactive!

    const { data } = useSWRV("https://cat-fact.herokuapp.com/facts")
    console.log("isReactive(data)", isReactive(data))
    setTimeout(() => {
      data.value = "hello"
    }, 5000)
    return { data }
    

    Works and will replace the result of the API call after 5 seconds.

    Am I doing something wrong or is something weird going on?

    Using Vue 2.6.12 and @vue/composition-api 1.0.0-rc.1...

    question 
    opened by bartenra 5
  • refactor(document-visible): modify isDocumentVisible timing

    refactor(document-visible): modify isDocumentVisible timing

    Consider this scenario.

    1. A user triggered a long time task to get a data, which might be longer than 15 seconds, in page A. useSWRV('dynamicKey', fetcher)
    2. Re-route to page B after the task done. The page B need to be constructed with data from that task.

    Issue: If the user switch to another Chrome tab when the task was running, then the page B won't be setup properly. Because the page B won't get data when calling useSWRV('dynamicKey').

    Expected: Should get data last known state when UI setup in document invisible mode.

    BTW, in SWR, you can get last known state, but won't trigger the fetcher. https://github.com/vercel/swr/blob/e76d30973bf623149ac4a61c81b0d3e4c8d79d93/src/use-swr.ts#L238-L253

    opened by NeoLSN 5
  • Is loading

    Is loading

    PR for https://github.com/Kong/swrv/issues/208

    Comments:

    1. Some cases of setting isLoading = false are not covered by tests. They follow analogical lines for isValidating. I only found a test case for one of them (the second changed line) and I am not sure whether isLoading is relevant there - if so, pls let me know I will try to extend the test case. The other two isValidating = false however do not break any tests when commented out. All these three lines are is a separate (second) commit.
    2. If this gets merged, SWRV docs site would need to be updated too.

    (Note: this is a second PR for #208. The first one (https://github.com/Kong/swrv/pull/284) has been created against the former next branch.)

    opened by ivos 0
  • Possible `key` type mismatch

    Possible `key` type mismatch

    According to docs something like this should be possible: image

    However, the following code triggers a TS type mismatch warning

    const maybeUndefined = ref<string>()
    
    const { data, error, mutate } = useSWRV(
      () => maybeUndefined.value && `my unuque key ${maybeUndefined.value}`,
      async () => {
        const r = await axiosInstance.get(`myUrl/${maybeUndefined.value}`)
        return r
      },
    )
    

    Warning reads:

    Argument of type '() => string | undefined' is not assignable to parameter of type 'IKey'.
      Type '() => string | undefined' is not assignable to type 'keyFunction'.ts(2345)
    

    Upon further digging the issue seems to be in type declaration for keyFunction

    export declare type keyType = string | any[] | null;
    declare type keyFunction = () => keyType;
    export declare type IKey = keyFunction | keyType;
    

    It would seem that amending keyType to

    export declare type keyType = string | any[] | null | undefined;
    

    would fix the issue.

    However I'm not sure if this doesn't break something down the line :)

    opened by mv-go 11
  • LocalStorage Improvements

    LocalStorage Improvements

    We've been using the localStorage adaptor extensively for some time and it's got some rough edges, which this pull request should address. This is our patched version, we've been using it in production for over a year.

    • It checks for expiration on initialisation (swrv may not have been active while an expiration occurred)
    • It avoids an error if setting localStorage fails (as a fallback)
    • It tries to recover from localStorage being full by deleting its own cache.

    To be honest, I don't think localStorage is the best tool for this because of its limitations, but it works well enough that I've not spent any time building an alternative adaptor.

    opened by mmulqueen 2
  • useSWRV does not revalidate if you call `mutate` and render another component right after

    useSWRV does not revalidate if you call `mutate` and render another component right after

    First of all, great lib, thanks

    If you call the global mutate method and right after render a component that uses useSRWV, the cache is not revalidated

    repro codesandbox

    Steps To test

    • click on the button "go to Route 2"
    • click on the button "Change cache"
    • click on the button "go to Route 1"

    if you open the browser dev tools and go to the networks tab you will see that the request to revalidate is not requested. If you wait a while in the Route 2 before go to Route 1, works fine

    opened by edumudu 0
Releases(v1.0.2)
  • v1.0.2(Dec 26, 2022)

  • v1.0.1(Nov 2, 2022)

  • v1.0.0(Oct 11, 2022)

    Summary

    Update swrv for Vue 3 officially on the master branch and release 1.0.0

    Breaking Changes

    • Upgrade Vue devDependency to ^3.2.40 and the Vue peerDependencies to >=3.2.26 < 4

    Other Changes

    • Switch from Vuepress to Vitepress for docs site now that we're on Vue 3

    Release strategy

    This PR will be merged into the master branch.

    As for package versioning:

    • This change will officially serve the Vue 3 version of swrv 1.x under the swrv@latest tag on npm.
    • The previous Vue 2.7 version of swrv 0.10.x will be available under the swrv@v2-latest tag on npm (this matches the vue@v2-latest tag for the [email protected] version)
    • The previous Vue <= 2.6.x version of swrv 0.9.6 will be available under the swrv@legacy tag on npm so anyone that cannot upgrade to Vue 2.7 can install (this matches the vue@legacy tag for the [email protected] version)
    Source code(tar.gz)
    Source code(zip)
  • v0.10.0(Aug 29, 2022)

    Summary

    Update swrv for Vue 2.7

    Breaking Changes

    • Upgrade Vue devDependency to ^2.7.x and the Vue peerDependencies to ^2.7.0
      • This internalizes the Vue Composition API and allows us to remove the @vue/composition-api peer dependency
    • This PR breaks SSR/Nuxt support. SSR significantly changed in Vue 3, and since this Vue 2.7 PR backports the changes already made for Vue 3, it loses SSR support. We're open to contributions if anyone would like to open a PR to add this feature back. (The SSR code and test(s) are commented out and remain in place).
    • See the Release strategy details in #304 on why we are not bumping the major version.

    Other Changes

    • Upgrades all @vue/cli-* dependencies to 5.x
      • Note: We're planning to swap out Vue CLI for Vite and Jest for Vitest in a future PR
    • Update tests for Vue 2.7, including the supported versions of Vue in test-compat-all.sh
    • Swaps out VitePress for VuePress for the documentation site since VitePress requires a conflicting Vue v3.x dependency

    Release strategy

    • This PR release for Vue 2.7 bumped the minor version to 0.10.x. We realize that this PR breaks SSR support and the major should actually be bumped; however, with the widespread usage of the beta branch we don't want to potentially break downstream projects that are already pointing to the 1.x major version.
    • The previous 0.9.6 release on npm will be tagged with legacy so anyone that cannot upgrade to Vue 2.7 can install with yarn add swrv@legacy (this matches the vue@legacy tag for the [email protected] version)
    • When we make the Vue 3 next branch the main branch in a future release, it will again bump the major version to 1.x
    Source code(tar.gz)
    Source code(zip)
  • v0.10.0-alpha.0(Aug 26, 2022)

  • v0.9.6(Feb 2, 2022)

  • v0.9.5(Jan 4, 2022)

  • v0.9.4(Jul 2, 2021)

    From #195

    Other changes:

    • improved error message for top level https://github.com/Kong/swrv/pull/134
    • update type https://github.com/Kong/swrv/pull/151
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta.8(Jan 29, 2021)

  • v0.9.3(Jan 29, 2021)

  • v1.0.0-beta.7(Jan 6, 2021)

  • v0.9.2(Jan 6, 2021)

  • v0.9.1(Dec 21, 2020)

  • v0.9.0(Dec 21, 2020)

    Adds Fetch API as the default fetcher, parity with swr Adapts SWRVCache slightly and adds first code built-in cache adapter LocalStorageCache. Also updates configs to allow for client defined webPresets e.g. isOnline, isDocumentVisible etc. to have parity with swr codebase.

    https://github.com/Kong/swrv/pull/123 https://github.com/Kong/swrv/pull/120

    Source code(tar.gz)
    Source code(zip)
  • v0.8.2(Dec 5, 2020)

    Latest swrv + @vue/composition-api

    [email protected]
    
    • remove tslib as dep #114
    • remove optional data?, error? as they are always defined since they are Refs #115

    Vue 3 version updated with all latest features cherry-picked into next

    [email protected]
    
    • error retries 830ac4c6dd096359586600a06ea03b8b1823abb2
    • array/object as key 909691946172354bf574a710c262e7e96e6aefc7
    • revaliate on mutate 415f8eb0d6a4dd85cf34c76997308448669c9514
    • ts paths f3ad412aa1408aedd99f1d16cf7e29b0295503af
    • tsc target to es5 ce75e60416d7c9c368bc36d54df9a488c40739fb
    • remove tslib as dep 05ffc66e16dda9114ad50d625e3e31726fd08112
    • remove optional data?, error? as they are always defined since they are Refs
    Source code(tar.gz)
    Source code(zip)
  • v0.8.1(Nov 6, 2020)

  • v0.8.0(Oct 20, 2020)

    • Error retries https://github.com/Kong/swrv/pull/94
    • Array/object as argument: https://github.com/Kong/swrv/issues/55
    • Fix typing of mutate https://github.com/Kong/swrv/issues/87
    Source code(tar.gz)
    Source code(zip)
  • v0.7.7(Oct 12, 2020)

  • v0.7.6(Sep 17, 2020)

  • v0.7.4(Sep 15, 2020)

  • v0.7.3(Aug 14, 2020)

  • v0.7.2(Jul 27, 2020)

  • v0.7.1(Jul 15, 2020)

  • v0.7.0(Jul 8, 2020)

  • v0.6.0(Jun 27, 2020)

  • v0.5.1(Jun 20, 2020)

  • v0.5.0(Jun 20, 2020)

    Adds fetcher as optional to serve from cache only without revalidation. See https://github.com/Kong/swrv#serve-from-cache-only for more information.

    Fixes #48

    Thanks to @NeoLSN for the issue!

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Jun 19, 2020)

    Added fix to watcher for support with 0.6.x and was able to get 0.5.x backwards compatibility support and added tests to CI so the source code and npm versions don't have to split.

    Fixes #46

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta.1(Jun 10, 2020)

    • added next branch with Vue 3 support for swrv.
    • Added Vue 3 support by removing the SSR implementation.
    • Added Vite example and added to readme
      • Go play around here! https://github.com/Kong/swrv/tree/next/examples/vite
    • Using latest vue-test-utils-next
    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(May 1, 2020)

Owner
Kong
The Cloud Connectivity Company. Community Driven & Enterprise Adopted.
Kong
This package allows you to show a placeholder-component while inertia fetches the content of ne new page while routing

inertia vue placeholder middleware This package adds a component placeholder middleware for inertia vue. instead of the InertiaProgressBar you can sho

null 6 Jul 24, 2022
:tada: A magical vue admin https://panjiachen.github.io/vue-element-admin

English | 简体中文 | 日本語 | Spanish SPONSORED BY 活动服务销售平台 客户消息直达工作群 Introduction vue-element-admin is a production-ready front-end solution for admin inter

花裤衩 80.1k Dec 31, 2022
:eyes: Vue in React, React in Vue. Seamless integration of the two. :dancers:

vuera NOTE: This project is looking for a maintainer! Use Vue components in your React app: import React from 'react' import MyVueComponent from './My

Aleksandr Komarov 4k Dec 30, 2022
🎉 基于 vite 2.0 + vue 3.0 + vue-router 4.0 + vuex 4.0 + element-plus 的后台管理系统vue3-element-admin

vue3-element-admin ?? 基于 Vite 2.0 + Vue3.0 + Vue-Router 4.0 + Vuex 4.0 + element-plus 的后台管理系统 简介 vue3-element-admin 是一个后台前端解决方案,它基于 vue3 和 element-plu

雪月欧巴 84 Nov 28, 2022
Jenesius vue modal is simple library for Vue 3 only

Jenesius Vue Modal Jenesius vue modal is simple library for Vue 3 only . Site Documentation Installation npm i jenesius-vue-modal For add modals in yo

Архипцев Евгений 63 Dec 30, 2022
A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

Azure Static Web App Template with Node.js API This is a template repository for creating Azure Static Web Apps that comes pre-configured with: Vue.js

Marc Duiker 6 Jun 25, 2022
Mosha-vue-toastify - A light weight and fun Vue 3 toast or notification or snack bar or however you wanna call it library.

Mosha Vue Toastify A lightweight and fun Vue 3 toast or notification or snack bar or however you wanna call it library. English | 简体中文 Talk is cheap,

Baidi Liu 187 Jan 2, 2023
A plugin that can help you create project friendly with Vue for @vue/cli 4.5

vue-cli-plugin-patch A plugin that can help you create project friendly with Vue for @vue/cli 4.5. Install First you need to install @vue/cli globally

null 2 Jan 6, 2022
Veloce: Starter template that uses Vue 3, Vite, TypeScript, SSR, Pinia, Vue Router, Express and Docker

Veloce Lightning-fast cold server start Instant hot module replacement (HMR) and dev SSR True on-demand compilation Tech Stack Vue 3: UI Rendering lib

Alan Morel 10 Oct 7, 2022
jump to local IDE source code while click the element of browser automatically.

?? Introduction A vite plugin which provides the ability that to jump to the local IDE when you click the element of browser automatically. It support

webfansplz 413 Dec 30, 2022
JavaScript data grid with a spreadsheet look & feel. Works for React, Angular, and Vue. Supported by the Handsontable team ⚡

Handsontable is a JavaScript component that combines data grid features with spreadsheet-like UX. It provides data binding, data validation, filtering

Handsontable 17.4k Dec 31, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.9k Jan 9, 2023
A Vue.js 2.0 UI Toolkit for Web

A Vue.js 2.0 UI Toolkit for Web. Element will stay with Vue 2.x For Vue 3.0, we recommend using Element Plus from the same team Links Homepage and doc

饿了么前端 53k Jan 3, 2023
The Intuitive Vue Framework

Build your next Vue.js application with confidence using Nuxt: a framework making web development simple and powerful. Links ?? Documentation: https:/

Nuxt 41.8k Jan 5, 2023
🐉 Material Component Framework for Vue

Supporting Vuetify Vuetify is a MIT licensed project that is developed and maintained full-time by John Leider and Heather Leider; with support from t

vuetify 36.2k Jan 3, 2023
🛠️ Standard Tooling for Vue.js Development

Vue CLI Vue CLI is the Standard Tooling for Vue.js Development. Documentation Docs are available at https://cli.vuejs.org/ - we are still working on r

vuejs 29.6k Jan 4, 2023
🗃️ Centralized State Management for Vue.js.

Vuex ?? HEADS UP! You're currently looking at Vuex 3 branch. If you're looking for Vuex 4, please check out 4.0 branch. Vuex is a state management pat

vuejs 27.9k Dec 30, 2022
A high quality UI Toolkit built on Vue.js 2.0

iView A high quality UI Toolkit built on Vue.js. Docs 3.x | 2.x | 1.x Features Dozens of useful and beautiful components. Friendly API. It's made for

iView 24k Jan 5, 2023
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

vue-next This is the repository for Vue 3.0. Quickstart Via CDN: <script src="https://unpkg.com/vue@next"></script> In-browser playground on Codepen S

vuejs 34.6k Jan 9, 2023