{"id":16292500,"url":"https://github.com/exogen/instant-listen","last_synced_at":"2026-05-07T01:06:56.670Z","repository":{"id":66194766,"uuid":"161892429","full_name":"exogen/instant-listen","owner":"exogen","description":"⚡️ Start listening before your request handlers are ready.","archived":false,"fork":false,"pushed_at":"2018-12-15T19:31:45.000Z","size":117,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T09:08:20.402Z","etag":null,"topics":["express","expressjs","nextjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/exogen.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,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"exogen","buy_me_a_coffee":"mosswood"}},"created_at":"2018-12-15T10:04:43.000Z","updated_at":"2020-06-12T03:47:47.000Z","dependencies_parsed_at":"2023-04-01T05:34:58.291Z","dependency_job_id":null,"html_url":"https://github.com/exogen/instant-listen","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.4444444444444444,"last_synced_commit":"accf15b96b791d711e4ff830d6b3593f3b1d61d9"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/exogen/instant-listen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Finstant-listen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Finstant-listen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Finstant-listen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Finstant-listen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exogen","download_url":"https://codeload.github.com/exogen/instant-listen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exogen%2Finstant-listen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268389106,"owners_count":24242726,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["express","expressjs","nextjs"],"created_at":"2024-10-10T20:07:13.201Z","updated_at":"2026-05-07T01:06:51.634Z","avatar_url":"https://github.com/exogen.png","language":"JavaScript","funding_links":["https://github.com/sponsors/exogen","https://buymeacoffee.com/mosswood"],"categories":[],"sub_categories":[],"readme":"# instant-listen\n\nDo you have an Express request handler that requires some preparation before\nit’s ready? This package makes it easy to set up a “deferred” handler that will\nallow the server to start listening earlier, then respond when the real handler\nis ready. That means you can start making requests right away, instead of\nrefreshing a bunch of “connection refused” pages while your app is bootstrapped.\n\n## Examples\n\n### Next.js with Express\n\nThis package is currently quite useful with Next.js in development mode, which\nhas a rather slow bootstrapping phase. There are two slow parts to Next.js’\nstartup time. The initial app creation:\n\n```js\n// This is a really slow synchronous/blocking call! \nconst app = next(/* ... */);\n```\n\nAnd the preparation, which performs a webpack build:\n\n```js\n// This is an even slower asynchronous call!\napp.prepare().then(/* ... */);\n```\n\nTypical [custom server instructions](https://github.com/zeit/next.js/tree/canary/examples/custom-server-express)\ndon’t call `listen()` until after both of these steps are complete, meaning if\nyou try to load the app in the meantime, you’ll get an error until the server is\nready to accept connections.\n\nUsing `instant-listen` makes it easy to start the slow bootstrapping phase after\nthe server is already listening:\n\n```js\nconst express = require(\"express\");\nconst next = require(\"next\");\nconst instantListen = require(\"instant-listen\");\n\nconst server = express();\n\nconst handler = instantListen(async () =\u003e {\n  const app = next({ dev: process.env.NODE_ENV !== \"production\" });\n  const handle = app.getRequestHandler();\n  await app.prepare();\n  return handle;\n});\n\nserver.get(\"*\", handler);\n\nserver.listen(3000, err =\u003e {\n  if (err) {\n    throw err;\n  }\n  console.log(`\u003e Ready on http://localhost:3000`);\n  handler.init();\n});\n```\n\n## Usage\n\n```js\n// CommonJS\nconst instantListen = require(\"instant-listen\");\n\n// ES2015\nimport instantListen from \"instant-listen\";\n```\n\nCall `instantListen` with a function that returns your request handler, or a\nPromise that resolves to a request handler.\n\n```js\nconst handler = instantListen(async () =\u003e {\n  // Do some work…\n  return myHandler;\n});\n```\n\nThe result is a new request handler that will delay responding to requests until\nit is ready to use your real handler. The handler function has two extra\nproperties:\n\n- `init`: A function to call when you’re ready for your handler creation\n  function to begin. In order to guarantee the server starts listening as soon\n  as possible, it’s best to do this after the server is already listening (like\n  in the `listen()` callback).\n- `ready`: A Promise that will resolve when the handler has been created and is\n  ready to respond to requests. You probably don’t need to use this, unless you\n  want to `catch` errors that occur during initialization.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Finstant-listen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexogen%2Finstant-listen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexogen%2Finstant-listen/lists"}