{"id":40715646,"url":"https://github.com/xiel/outer-hooks","last_synced_at":"2026-01-21T13:10:33.374Z","repository":{"id":40538842,"uuid":"413038972","full_name":"xiel/outer-hooks","owner":"xiel","description":"Powerful and composable hooks that work in Node \u0026 Browser.","archived":false,"fork":false,"pushed_at":"2023-01-06T22:32:33.000Z","size":1318,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-01T09:02:53.445Z","etag":null,"topics":["functional-programming","hook","hooks","node","typescript"],"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/xiel.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":"2021-10-03T10:00:51.000Z","updated_at":"2023-03-07T14:06:34.000Z","dependencies_parsed_at":"2023-02-06T09:47:20.207Z","dependency_job_id":null,"html_url":"https://github.com/xiel/outer-hooks","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/xiel/outer-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiel%2Fouter-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiel%2Fouter-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiel%2Fouter-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiel%2Fouter-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiel","download_url":"https://codeload.github.com/xiel/outer-hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiel%2Fouter-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["functional-programming","hook","hooks","node","typescript"],"created_at":"2026-01-21T13:10:32.710Z","updated_at":"2026-01-21T13:10:33.366Z","avatar_url":"https://github.com/xiel.png","language":"TypeScript","readme":"\n\n# OuterHooks 💫\n[![npm (tag)](https://img.shields.io/npm/v/@xiel/outer-hooks?color=blue)](https://www.npmjs.com/package/@xiel/outer-hooks)\n![GitHub top language](https://img.shields.io/github/languages/top/xiel/outer-hooks.svg)\n\n\nCreate function components using powerful and composable hooks.\n\nIf you know and love [hooks from React](https://reactjs.org/docs/hooks-intro.html), you already know the main API of OuterHooks as they are very alike.\n\n### Differences to React\n\n- OuterHooks is plain JavaScript/TypeScript\n- No JSX here – does not render to the DOM or any UI really\n- Only compose logic using native \u0026 custom hooks\n- Life cycle hooks like useEffect also run in Node\n\n## Install\n\n```\nyarn add @xiel/outer-hooks\n```\n\n#### Warning: Work in progress\n\nThis library is still in **beta**. It works, is well tested and actively being developed. But the API is not 100% stable yet.\n\n## Hooks\n\n### Native Hooks\n\n- useState, useRef, useMemo, useCallback, useReducer, useEffect, useLayoutEffect, ...\n\nFor now please check the React [Hooks API reference](https://reactjs.org/docs/hooks-reference.html) as they work exactly the same in OuterHooks.\n\n### Custom Hooks\n\nBy composing native hooks, you are creating a custom hook. Native hooks and custom hooks can be composed and nested.\n\n#### Example\n\n```ts\n// Define a custom hook\nfunction useCustomHook() {\n  const [currentState, setState] = useState(0)\n\n  useEffect(() =\u003e {\n    if (currentState \u003c 5) {\n      setState(currentState + 1)\n    }\n  }, [currentState])\n\n  return currentState\n}\n\n// Run the hook\nconst custom = runHook(useCustomHook)\n\n// Gets called every time the hook has run\n// In this example it will get called with the values 0, 1, 2, 3, 4, 5\ncustom.on('update', (value) =\u003e console.log(value))\n\n// Gets called when the hook was destroyed\ncustom.on('destroy', (error) =\u003e console.error('destroyed'))\n```\n\n#### runHook(fn)\n\nrunHook(fn) returns the following interface, which lets you await the next value, await effects, read the latest value and subscribe to updates to your hook.\n\n```ts\nexport interface Root\u003cProps, HookValue\u003e {\n  displayName: string\n\n  /**\n   * Resolves once the hooks has rendered.\n   * Might resolve after being intermediately suspended.\n   */\n  value: Promise\u003cHookValue\u003e\n\n  /**\n   * Resolves once all side effects have run (cleanups, useLayoutEffects and useEffects)\n   */\n  effects: Promise\u003cvoid\u003e\n\n  /**\n   * Returns the current value of the ran hook (outermost custom `useXYZ` hook)\n   * This might return undefined or a stole/older value while the hook is suspended.\n   * Recommended: Use the value promise to get the latest value.\n   */\n  currentValue?: HookValue\n\n  /**\n   * While the hook is suspended, this will return true\n   */\n  isSuspended: boolean\n\n  /**\n   * If the hook was destroyed (by error or externally), this will return true\n   */\n  isDestroyed: boolean\n\n  /**\n   * Resolves after all cleanup functions have run\n   */\n  isDestroyedPromise: Promise\u003cunknown\u003e | undefined\n\n  /**\n   * Re-run the hook with new props\n   */\n  render: RenderFn\u003cProps, HookValue\u003e\n\n  /**\n   * Re-run the hook with (partially) new props.\n   */\n  update: UpdateFn\u003cProps, HookValue\u003e\n\n  /**\n   * Subscribe to hook updates\n   */\n  on: \u003cT extends keyof SubscriptionTypes\u003e(\n    type: T,\n    subscription: SubscriptionTypes\u003cHookValue\u003e[T]\n  ) =\u003e UnsubscribeFn\n\n  /**\n   * Unsubscribe from hook updates\n   */\n  off: \u003cT extends keyof SubscriptionTypes\u003e(\n    type: T,\n    subscription: SubscriptionTypes\u003cHookValue\u003e[T]\n  ) =\u003e void\n\n  /**\n   * Destroy the hook.\n   * This will run all cleanup functions and reject the value promise\n   */\n  destroy(reason?: unknown): Promise\u003cunknown\u003e\n}\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiel%2Fouter-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiel%2Fouter-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiel%2Fouter-hooks/lists"}