{"id":13824126,"url":"https://github.com/jfet97/vue-use-infinite-scroll","last_synced_at":"2025-07-08T19:30:45.690Z","repository":{"id":42723121,"uuid":"284088152","full_name":"jfet97/vue-use-infinite-scroll","owner":"jfet97","description":"A Vue composition function that makes infinite scroll a breeze.","archived":false,"fork":false,"pushed_at":"2023-07-18T23:06:33.000Z","size":179,"stargazers_count":111,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-21T18:46:33.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfet97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-31T17:04:14.000Z","updated_at":"2024-04-25T03:51:26.000Z","dependencies_parsed_at":"2024-01-08T08:57:05.528Z","dependency_job_id":null,"html_url":"https://github.com/jfet97/vue-use-infinite-scroll","commit_stats":{"total_commits":12,"total_committers":3,"mean_commits":4.0,"dds":"0.41666666666666663","last_synced_commit":"42ef35754bfd3cfa1cdde4e5f16a458c2e1835a0"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfet97%2Fvue-use-infinite-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfet97%2Fvue-use-infinite-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfet97%2Fvue-use-infinite-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfet97%2Fvue-use-infinite-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfet97","download_url":"https://codeload.github.com/jfet97/vue-use-infinite-scroll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":256939844,"owners_count":22465641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:00:57.199Z","updated_at":"2025-07-08T19:30:45.412Z","avatar_url":"https://github.com/jfet97.png","language":"TypeScript","funding_links":[],"categories":["Packages","Utilities [🔝](#readme)","TypeScript","Components \u0026 Libraries"],"sub_categories":["Utilities"],"readme":"# vue-use-infinite-scroll\n\n## Installation\n\n```sh\nnpm i -S vue-use-infinite-scroll\n```\n\n## Usage\n\n### template\n\n```html\n\u003cdiv\u003e\n    \u003cspan\u003e{{ errorMessageRef }}\u003c/span\u003e\n    \u003cul\u003e\n        \u003cli v-for=\"item in itemsRef\" :key=\"item.id\"\u003e{{ item }}\u003c/li\u003e\n\n        \u003c!-- DOM element used as trigger --\u003e\n        \u003cdiv ref=\"intersectionTrigger\"\u003e\u003c/div\u003e\n    \u003c/ul\u003e\n\u003c/div\u003e\n```\n\n### script\n\n```js\nimport { ref, watch } from 'vue'\nimport { makeUseInfiniteScroll } from 'vue-use-infinite-scroll'\n\nexport default {\n    setup() {\n        // INTERSECTION OBSERVER\n\n        // set the intersection options object\n        // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\n        const useInfiniteScroll = makeUseInfiniteScroll({}) // the argument is optional\n\n        // create the template ref for the element that\n        // will trigger the intersection observer\n        const intersectionTrigger = ref(null) // as Ref\u003cHTMLElement\u003e\n\n        // useInfiniteScroll returns a pageRef, starting from page 1,\n        // which changes we should listen to fetch more data\n        const pageRef = useInfiniteScroll(intersectionTrigger)\n\n        watch(\n            pageRef,\n            (page) =\u003e {\n                fetchItems(page)\n            },\n            { immediate: true }\n        )\n\n        // DATA\n\n        const itemsRef = ref([])\n        const errorMessageRef = ref('')\n\n        async function fetchItems(page) {\n            fetch(`https://jsonplaceholder.typicode.com/comments?_page=${page}\u0026_limit=10`)\n                .then((res) =\u003e res.json())\n                .then((data) =\u003e itemsRef.value.push(...data))\n                .catch((error) =\u003e (errorMessageRef.value = error.message))\n        }\n\n        return { intersectionTrigger, itemsRef, errorMessageRef }\n    },\n}\n```\n\nTry it [here](https://codesandbox.io/s/vue-use-infinite-scroll-vclfp?file=/src/App.vue) 🙂!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfet97%2Fvue-use-infinite-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfet97%2Fvue-use-infinite-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfet97%2Fvue-use-infinite-scroll/lists"}