{"id":13456904,"url":"https://github.com/bartlomiejzuber/use-open-window","last_synced_at":"2025-04-24T04:14:42.236Z","repository":{"id":36504816,"uuid":"227938247","full_name":"bartlomiejzuber/use-open-window","owner":"bartlomiejzuber","description":"React hook to open links in separate windows ✔️","archived":false,"fork":false,"pushed_at":"2025-01-23T04:40:15.000Z","size":1995,"stargazers_count":13,"open_issues_count":6,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T04:14:37.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://use-open-window-demo.netlify.app/","language":"HTML","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/bartlomiejzuber.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}},"created_at":"2019-12-13T23:24:09.000Z","updated_at":"2024-11-22T20:42:18.000Z","dependencies_parsed_at":"2024-05-31T10:07:58.430Z","dependency_job_id":"602c7d80-7ff5-42a8-b1cb-f2db64e020a7","html_url":"https://github.com/bartlomiejzuber/use-open-window","commit_stats":null,"previous_names":["bartlomiejzuber/useopeninwindow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartlomiejzuber%2Fuse-open-window","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartlomiejzuber%2Fuse-open-window/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartlomiejzuber%2Fuse-open-window/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bartlomiejzuber%2Fuse-open-window/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bartlomiejzuber","download_url":"https://codeload.github.com/bartlomiejzuber/use-open-window/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250560055,"owners_count":21450173,"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-07-31T08:01:29.820Z","updated_at":"2025-04-24T04:14:42.217Z","avatar_url":"https://github.com/bartlomiejzuber.png","language":"HTML","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"## use-open-window\n\n![react hook](https://badgen.net/badge/icon/react-hook?icon=libraries\u0026label)\n![fully typed](https://badgen.net/badge/icon/fully-typed?icon=typescript\u0026label)\n[![npm](https://img.shields.io/npm/l/hooked-react-stopwatch.svg)](https://www.npmjs.com/package/use-open-window)\n[![npm](https://badgen.net/bundlephobia/minzip/use-open-window)](https://www.npmjs.com/package/use-open-window)\n[![Coverage Status](https://coveralls.io/repos/github/bartlomiejzuber/use-open-window/badge.svg)](https://coveralls.io/github/bartlomiejzuber/use-open-window)\n[![License](https://img.shields.io/npm/v/use-open-window.svg)](https://github.com/bartlomiejzuber/use-open-window/blob/master/LICENSE)\n[![Netlify Status](https://api.netlify.com/api/v1/badges/d360c27d-3707-4eb8-a0bd-b6e0d65a3e22/deploy-status)](https://app.netlify.com/sites/use-open-window-demo/deploys)\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/bartlomiejzuber/use-open-window/master/assets/icon.png\" alt=\"hook icon\"/\u003e\n\u003c/p\u003e\n\nUseful \u0026 super tiny (less than 1KB ✔️) (❤️obvious dep on React only) hook to open links in new window.\n\n\u003e **Note**: Version `^1.4.0` of this hook has dependency on `React 18`, if you wish to use it with `React 17` then please use version `^1.3.0`.\n\n## Installation\n\n```sh\nnpm i use-open-window --save\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add use-open-window\n```\n\nLink to npm:\n[https://www.npmjs.com/package/use-open-window](https://www.npmjs.com/package/use-open-window)\n\n### Click here to see [DEMO](https://use-open-window-demo.netlify.app/)\n\n### Demo\n\n![Demo GIF](/assets/demo-gif.gif)\n\n## Usage\n\n- With URL and options passed to hook\n  ```javascript\n  import { useOpenInWindow }  from 'use-open-window';\n\n  const url = 'https://www.google.com/';\n  const options = {\n    centered: true, /* default */\n    security: {\n      noopener: true,    /* default */\n      noreferrer: true,  /* default */\n      nofollow: false    /* default */\n    },\n    specs: {\n      width: 800,  /* window width */\n      height: 600, /* window height */\n    }\n  };\n  const App = () =\u003e {\n    const [handleWindowOpen, newWindowHandle] = useOpenInWindow(url, options);\n    \n    return (\n      \u003cdiv className=\"App\"\u003e\n        \u003cdiv onClick={handleWindowOpen}\u003eClick me\u003c/div\u003e\n      \u003c/div\u003e\n    );\n  }\n\n  export default App;\n  ```\n- With URL and options passed inside callback\n  ```javascript\n  import { useOpenInWindow }  from 'use-open-window';\n\n  const options = {\n    url: 'https://www.google.com/' /* url to page to open */\n    centered: true, /* default */\n    security: {\n      noopener: true,    /* default */\n      noreferrer: true,  /* default */\n      nofollow: false    /* default */\n    },\n    specs: {\n      width: 800,  /* window width */\n      height: 600, /* window height */\n    }\n  };\n  const App = () =\u003e {\n    const [handleWindowOpen, newWindowHandle] = useOpenInWindow();\n    \n    return (\n      \u003cdiv className=\"App\"\u003e\n        \u003cdiv onClick={(ev) =\u003e handleWindowOpen(ev, options)}\u003eClick me\u003c/div\u003e\n      \u003c/div\u003e\n    );\n  }\n\n  export default App;\n  ```\n\n### Hook params\n\n| Parameter | Type                   | Description                                             | Required |\n|-----------|------------------------|---------------------------------------------------------|----------|\n| url       | string                 | Url to load inside new window                           | Y        |\n| options   | UseOpenInWindowOptions | Set of hook options (centered, focus, window size etc.) | N        |\n\n#### Options\n\n| Option           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Default   |\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|\n| name             | Specifies the target attribute or the name of the window. The following values are supported:\u003cbr\u003e\u003cbr\u003e        _blank - URL is loaded into a new window, or tab.\u003cbr\u003e\u003cbr\u003e        _parent - URL is loaded into the parent frame\u003cbr\u003e\u003cbr\u003e        _self - URL replaces the current page\u003cbr\u003e\u003cbr\u003e        _top - URL replaces any framesets that may be loaded\u003cbr\u003e\u003cbr\u003e        name - The name of the window (Note: the name does not specify the title of the new window) | _blank    |\n| centered         | Specifies if window should be centered                                                                                                                                                                                                                                                                                                                                                                                                                          | true      |\n| focus            | Puts new window in focus                                                                                                                                                                                                                                                                                                                                                                                                                                        | true      |\n| security.noopener| Prevents the opened page from having access to the window.opener property                                                                                                                                                                                                                                                                                                                                                                                       | true      |\n| security.noreferrer| Prevents passing the referrer information to the opened page                                                                                                                                                                                                                                                                                                                                                                                                  | true      |\n| security.nofollow| Instructs search engines not to follow the link                                                                                                                                                                                                                                                                                                                                                                                                                | false     |\n| specs.width      | The width of the window. Min. value is 100 (browser restriction).                                                                                                                                                                                                                                                                                                                                                                                               | 800       |\n| specs.height     | The height of the window. Min. value is 100 (browser restriction).                                                                                                                                                                                                                                                                                                                                                                                              | 800       |\n| left             | The left position of the window. Negative values not allowed.                                                                                                                                                                                                                                                                                                                                                                                                   | undefined |\n| top              | The top position of the window. Negative values not allowed.                                                                                                                                                                                                                                                                                                                                                                                                    | undefined |\n| location         | Whether or not to display the address field                                                                                                                                                                                                                                                                                                                                                                                                                     | null      |\n| menubar          | Whether or not to display the menu bar                                                                                                                                                                                                                                                                                                                                                                                                                          | null      |\n| scrollbars       | Whether or not to display scroll bars                                                                                                                                                                                                                                                                                                                                                                                                                           | yes       |\n| status           | Whether or not to add a status bar                                                                                                                                                                                                                                                                                                                                                                                                                              | null      |\n| titlebar         | Whether or not to display the title bar                                                                                                                                                                                                                                                                                                                                                                                                                         | null      |\n| toolbar          | Whether or not to display the browser toolbar                                                                                                                                                                                                                                                                                                                                                                                                                   | null      |\n\nDependencies ![Deps](https://badgen.net/npm/dependents/use-open-window)\n--------\nNone. Self source code only. (❤️obvious peer dep on React only)\n\nReliability\n--------\nThis package is fully tested with total coverage set to [![Coverage Status](https://coveralls.io/repos/github/bartlomiejzuber/use-open-window/badge.svg)](https://coveralls.io/github/bartlomiejzuber/use-open-window). If you found any issue please report it [here](https://github.com/bartlomiejzuber/use-open-window/issues/new).\n\nLicense\n--------\n\nMade with :sparkling_heart: by [Bartlomiej Zuber (bartlomiej.zuber@outlook.com)](mailto:bartlomiej.zuber@outlook.com) while traveling around the world, and licensed under the [MIT License](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartlomiejzuber%2Fuse-open-window","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartlomiejzuber%2Fuse-open-window","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartlomiejzuber%2Fuse-open-window/lists"}