Know when your users are idle ⏳

Overview

Features | Demo

No dependencies — TypeScript — SSR support — Readable store for idle value — onIdle callback

Installation

npm i svelte-idle

Usage

<script>
import { start, idle, onIdle } from 'svelte-idle'

// Run start on component Initialization
start()

// Run code when user idle via callback...
onIdle(() => {
    console.log('User is idle')
})

//... or by using the idle store
$: {
    if($idle) console.log('User is idle')
}
</script>

User is idle: {$idle}

API

start

The start method accepts an optional object (type: StartOpts). The following values can be defined:

milliseconds

  • type: number
  • defines: how long before the user is udle

throttle_milliseconds

  • type: number
  • defines: amount of milliseconds before each idle-check

Example:

import { start } from 'svelte-idle'

start({
    milliseconds: 60_000,
    throttle_milliseconds: 500
})

idle

A readable store that reflects the current idle-state.

onIdle

Callback which will be fired everytime idle becomes true. Returns a method for clearing the listener.

Example:

import { onMoumt } from 'svelte'
import { onIdle } from 'svelte-idle'

onMount(() => {
    const unsub = onIdle(() => console.log('User is idle!'))
    return unsub
})
You might also like...

Adapter for SvelteKit apps that prerenders your site as a collection of static files for GitHub Pages

svelte-adapter-github Adapter for SvelteKit apps that prerenders your site as a collection of static files for GitHub Pages. Usage Install with npm i

Sep 20, 2022

Add Routify to your Svelte project

🎀 Add (work in progress) Routify to Svelte This is an adder for svelte-add; you should read its README before continuing here. ➕ Adding (work in prog

Aug 3, 2022

This is a heart of RainbowBOT. You can also build your own bots with this core!

RainbowBOT Core RainbowBOT Core - is a Discord BOT core with rich functionality. This core takes over many routine things like data storing, interacti

Apr 26, 2022

An app to organize and track your downloaded anime.

An app to organize and track your downloaded anime.

My Personal List An app to organize and track your downloaded anime. Usage • Features • Installation and Running • Building 🚀️ Usage and Conventions

Dec 29, 2022

🌈 what's your GitHub profile color?

🌈 what's your GitHub profile color?

🌈 OctoColor 🤔 Wanna know what's your GitHub Profile Color? 🐱 Head over to https://octocolor.vercel.app 🐱‍💻 How does GitColor work? The idea is si

Sep 22, 2022

Admin UI Template is a modern, responsive, and customizable admin UI template for your business.

Admin UI Template is a modern, responsive, and customizable admin UI template for your business.

Admin UI Template is a modern, responsive, and customizable admin UI template for your business. It contains reusable components, theme color, and design support along with dark theme support.

Dec 18, 2022

Easily connect your Nuxt 3 application with LogSnag 📰

Easily connect your Nuxt 3 application with LogSnag 📰

Nuxt LogSnag 📰 LogSnag integration for Nuxt 3 ✨ Release Notes Features Nuxt 3 ready Easy integration Handy composables TypeScript support Setup Insta

Apr 28, 2022

Write CSS modules without leaving your javascript!

vite-plugin-inline-css-modules Write CSS modules without leaving your javascript! Zero Runtime Contains full feature set of CSS modules (Includes Post

Jan 2, 2023

Help you solve the Wordle puzzles when your vocabulary failes you.

Help you solve the Wordle puzzles when your vocabulary failes you.

Wordle Helper Help you solve Wordle puzzles when your vocabulary failes you. Have fun with it here: wordle.zxh.io How to use First, start a Wordle puz

Jun 20, 2022
Comments
  • Linked Demo Not Working

    Linked Demo Not Working

    Hi, Just thought you'd like to know the demo you have linked from the project doesn't seem to work.

    https://svelte.dev/repl/005264a7de2446728aee059bb6fcbc46?version=3.46.4

    Using chrome 104.0.5112.102

    $idle is never true.

    image

    opened by pragmat1c 2
:necktie: :briefcase: Build fast :rocket: and easy multiple beautiful resumes and create your best CV ever! Made with Vue and LESS.

best-resume-ever ?? ?? Build fast ?? and easy multiple beautiful resumes and create your best CV ever! Made with Vue and LESS. Cool Creative Green Pur

Sara Steiert 15.8k Jan 9, 2023
Matteo Bruni 4.7k Jan 4, 2023
The first truly composable CSS animation library. Built for Vue, React, SCSS, and CSS, AnimXYZ will bring your website to life.

AnimXYZ animxyz.com AnimXYZ helps you create, customize, and compose animations for your website. Powered by CSS variables to allow a nearly limitless

Ingram Projects 2.1k Jan 2, 2023
A simple, customization star rating component for your vue3 projects

vue3-star-ratings A simple, customizable component for star ratings Documentation Features Uses svg for the stars, so it can scale without quality los

Abiodun Olunu 14 Oct 7, 2022
Backs up your favourite and recently used gifs/emotes and restores them in case discord clears them after logouts or for other reasons

Persist Favourites This plugin solves the problem of Discord randomly deciding to clear your gifs or emotes by backing both up regularely and restorin

Vens Powercord Plugins 18 Oct 13, 2022
quickly start your Vue dev server

vue-fast-dev-server 10倍缩短您的vue dev server启动时间 安装 npm install vue-fast-dev-server --save-dev vue.config.js const path = require('path') module.exports

null 22 Feb 28, 2022
OSI helps you to track your all open-source Internships and Program in a single place ⚡

Open Source Internships Overview ?? Dark Theme Light Theme Run locally ?? Fork this repo. open-source-internships ?? Clone the repo. ⏬ git clone https

Rohan kumar 39 Jan 2, 2023
Add linked data to the YAML of your Obsidian notes.

Obsidian Linked Data Vocabularies Plugin This plugin adds YAML keys for the selected heading, url (optional), and broader, narrower and related headin

null 53 Oct 13, 2022
Automatically configure Vitest from your SvelteKit configuration.

vitest-svelte-kit Automatically configure Vitest from your SvelteKit configuration. Getting Started Installing In an existing SvelteKit project, run t

Nick Breaton 44 Dec 30, 2022
Some compile-time magic for your Vite project

?? You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. vite-plugin-compile-time Use this plugin to generate

EGOIST 90 Dec 15, 2022