{"id":15287001,"url":"https://github.com/jsheaven/runtime-info","last_synced_at":"2026-02-01T21:02:28.481Z","repository":{"id":65693398,"uuid":"597504903","full_name":"jsheaven/runtime-info","owner":"jsheaven","description":"Isomorphic, nano-sized library for runtime detection: isServer(), isBrowser(), isWebWorker()","archived":false,"fork":false,"pushed_at":"2023-02-05T02:49:26.000Z","size":60,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T02:02:28.584Z","etag":null,"topics":["browser","deno","javascript","nodejs","runtime","ssg","ssr","typescript","webworker"],"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/jsheaven.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}},"created_at":"2023-02-04T18:53:22.000Z","updated_at":"2023-02-06T08:36:57.000Z","dependencies_parsed_at":"2023-02-18T21:16:01.105Z","dependency_job_id":null,"html_url":"https://github.com/jsheaven/runtime-info","commit_stats":null,"previous_names":["kyr0/runtime-info"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsheaven/runtime-info","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fruntime-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fruntime-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fruntime-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fruntime-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsheaven","download_url":"https://codeload.github.com/jsheaven/runtime-info/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsheaven%2Fruntime-info/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28990694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T20:57:35.821Z","status":"ssl_error","status_checked_at":"2026-02-01T20:57:29.580Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["browser","deno","javascript","nodejs","runtime","ssg","ssr","typescript","webworker"],"created_at":"2024-09-30T15:20:15.836Z","updated_at":"2026-02-01T21:02:28.466Z","avatar_url":"https://github.com/jsheaven.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eruntime-info\u003c/h1\u003e\n\n\u003e Nano untility library for JavaScript runtime detection\n\n\u003ch2 align=\"center\"\u003ePurpose\u003c/h2\u003e\n\nThis is important for SSR/SSG, isomorphic runtime code checks: Should certain code be executed or not?\nSome code works only on server, some code works in browser, and some in browser, but not in WebWorkers.\n\nInstead of a weak `if (typeof window !== 'undefined') { ... }` etc. checks which are easy to mistaken\nyou can use this safe, fast and nano sized library. Using it gives you more readable code and reliability.\n\n\u003ch2 align=\"center\"\u003eFeatures\u003c/h2\u003e\n\n- ✅ JavaScript runtime checks: `isBrowser()`, `isServer()`, `isWebWorker()`\n- ✅ Just `174 byte` nano sized (ESM, gizpped)\n- ✅ Tree-shakable, side-effect free, so maybe just `~58 byte` for you\n- ✅ Zero dependencies\n- ✅ First class TypeScript support\n- ✅ 100% Unit Test coverage\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n- yarn: `yarn add runtime-info`\n- npm: `npm install runtime-info`\n\n\u003ch2 align=\"center\"\u003eUse\u003c/h2\u003e\n\n\u003ch3 align=\"center\"\u003eESM\u003c/h2\u003e\n\n```ts\nimport { isBrowser, isServer, isWebWorker } from 'runtime-info'\n\nif (isBrowser()) {\n  // safely use window, location, etc. here\n}\n\nif (isServer()) {\n  // safely use Node.js/Deno API's here like process\n}\n\nif (isWebWorker()) {\n  // safely use postMessage() inside of a webworker\n}\n```\n\n\u003ch3 align=\"center\"\u003eCommonJS\u003c/h2\u003e\n\n```ts\nconst { isBrowser, isServer, isWebWorker } = require('runtime-info')\n\n// same API like ESM variant\n```\n\n\u003ch2 align=\"center\"\u003eOne thing about JSDOM\u003c/h2\u003e\n\nIf you're running inside of a server-side environment where globals like `window` and `document`\nare defined (JSDOM), then you're effectively running in a browser-compatible environment, and\nthis library will return `true` for `isBrowser` and `false` for `isServer`. This is an edge case.\nYou can check for this using the following code: `navigator.userAgent.includes(\"jsdom\")`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Fruntime-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsheaven%2Fruntime-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsheaven%2Fruntime-info/lists"}