{"id":13838894,"url":"https://github.com/charpeni/react-native-url-polyfill","last_synced_at":"2025-05-14T13:10:01.475Z","repository":{"id":39453733,"uuid":"223323495","full_name":"charpeni/react-native-url-polyfill","owner":"charpeni","description":"🔗A lightweight and trustworthy URL polyfill for React Native.","archived":false,"fork":false,"pushed_at":"2025-04-12T21:19:03.000Z","size":3507,"stargazers_count":364,"open_issues_count":9,"forks_count":23,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T13:17:29.335Z","etag":null,"topics":["javascript","polyfill","react-native","url","urlsearchparams","whatwg-url"],"latest_commit_sha":null,"homepage":"","language":"Java","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/charpeni.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-11-22T04:28:41.000Z","updated_at":"2025-05-11T15:32:26.000Z","dependencies_parsed_at":"2025-03-25T01:50:28.731Z","dependency_job_id":null,"html_url":"https://github.com/charpeni/react-native-url-polyfill","commit_stats":{"total_commits":323,"total_committers":7,"mean_commits":"46.142857142857146","dds":0.4365325077399381,"last_synced_commit":"1272c4dafffd148a80e017eb7d247891d0f8cd90"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charpeni%2Freact-native-url-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charpeni%2Freact-native-url-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charpeni%2Freact-native-url-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charpeni%2Freact-native-url-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charpeni","download_url":"https://codeload.github.com/charpeni/react-native-url-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149977,"owners_count":22022852,"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":["javascript","polyfill","react-native","url","urlsearchparams","whatwg-url"],"created_at":"2024-08-04T16:00:37.585Z","updated_at":"2025-05-14T13:09:56.461Z","avatar_url":"https://github.com/charpeni.png","language":"Java","readme":"# React Native URL Polyfill\n\n\u003cimg height=\"125\" src=\"https://user-images.githubusercontent.com/7189823/69501658-06047600-0ed5-11ea-8f54-952bf1afd68c.png\" alt=\"Library's logo\" align=\"right\"\u003e\n\n[![Version](https://badge.fury.io/js/react-native-url-polyfill.svg)](https://www.npmjs.org/package/react-native-url-polyfill)\n[![Monthly Downloads](https://img.shields.io/npm/dm/react-native-url-polyfill)](https://www.npmjs.org/package/react-native-url-polyfill)\n[![CircleCI Status](https://circleci.com/gh/charpeni/react-native-url-polyfill.svg?style=shield)](https://circleci.com/gh/charpeni/react-native-url-polyfill)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/charpeni/react-native-url-polyfill/blob/main/LICENSE)\n\nA lightweight and trustworthy URL polyfill for React Native, based on the WHATWG [URL Standard](https://url.spec.whatwg.org/) optimized for React Native.\n\n\u003cbr /\u003e\n\n- **Lightweight**. Uses a forked version of [`whatwg-url`](https://github.com/jsdom/whatwg-url) ([`whatwg-url-without-unicode`](https://github.com/charpeni/whatwg-url)) where Unicode support has been stripped out—Going down from [372 KB](https://bundlephobia.com/result?p=whatwg-url@8.0.0) to [40.9 KB](https://bundlephobia.com/result?p=whatwg-url-without-unicode@8.0.0-3).\n- **Trustworthy**. Follows the URL Standard spec, and relies on unit tests and Detox e2e tests within [React Native](https://github.com/facebook/react-native).\n- **Blob support**. Supports React Native's Blob without additional steps.\n- **Hermes support**. Supports [Hermes](https://github.com/facebook/hermes), a JavaScript engine optimized for running React Native.\n- **Expo support**. Supports [Expo](https://expo.dev/) and tested against.\n- **Web support**. Most of the time, this polyfill isn't useful on web and therefore using `react-native-url-polyfill/auto` will be no-op on web.\n\n\u003e [!IMPORTANT]\n\u003e As mentioned above, Unicode support has been stripped out to keep this polyfill lightweight on mobile. Therefore, [non-ASCII characters](https://unicode.org/reports/tr46/) aren't supported in the hostname.\n\n## Why do we need this?\n\nReact Native does include [a polyfill for `URL`](https://github.com/facebook/react-native/blob/8c0c860e38f57e18296f689e47dfb4a54088c260/Libraries/Blob/URL.js#L115-L222), but this polyfill is homemade—in order to keep it light-weight—and was initially created to handle specific use cases.\n\nMeanwhile, React Native has grown around that polyfill, then some unexpected errors have arisen.\n\n\u003e [!NOTE]\n\u003e Known issues (non-exhaustive) with React Native's URL are:\n\u003e\n\u003e - URL cannot handle \"localhost\" domain for base url [react-native#26019](https://github.com/facebook/react-native/issues/26019).\n\u003e - URL implementation should add a trailing slash to the base [react-native#25717](https://github.com/facebook/react-native/issues/25717).\n\u003e - URL incorrectly adds trailing slash [react-native#24428](https://github.com/facebook/react-native/issues/24428).\n\u003e - Creating an instance of URL like: `new URL('http://facebook.com')` throws an exception [react-native#16434](https://github.com/facebook/react-native/issues/16434).\n\nThat's why you may need this external dependency. If you use [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) within your app, you should look at the installation steps below!\n\nUnfortunately, adding `react-native-url-polyfill` to React Native source code would mean adding 📦 **73.67 KB** (as of RN 0.72) to the JavaScript bundle, that's why it's not included by default.\n\n## Installation\n\nFirst, you need to install the polyfill, which can be done with [Yarn](https://yarnpkg.com/), [npm](https://www.npmjs.com/), and others.\n\n```bash\nyarn add react-native-url-polyfill\n```\n\nThen, the polyfill can be used in multiple ways. Pick your preferred option.\n\n\u003e [!TIP]\n\u003e To verify if the polyfill has been correctly applied, you can check if the global variable `REACT_NATIVE_URL_POLYFILL` contains the current package and version like: `react-native-url-polyfill@CURRENT_VERSION`.\n\n### Option 1 (_Simple_)\n\nLocate your JavaScript entry-point file, commonly called `index.js` at the root of your React Native project.\n\nThen, import `react-native-url-polyfill/auto` at the top of your entry-point file, the polyfill will be automatically applied.\n\n```javascript\nimport 'react-native-url-polyfill/auto';\n```\n\n### Option 2 (_Flexible_)\n\nIf you want to apply the polyfill when you're ready, you can import `setupURLPolyfill` and call it yourself.\n\n```javascript\nimport { setupURLPolyfill } from 'react-native-url-polyfill';\n\nsetupURLPolyfill();\n```\n\n### Option 3 (_Convenient_ / ponyfill)\n\nIf you prefer not to apply this polyfill over React Native's default `URL`, you can still import those classes manually when you want them.\n\n```javascript\nimport { URL, URLSearchParams } from 'react-native-url-polyfill';\n\nconst url = new URL('https://github.com');\nconst searchParams = new URLSearchParams('q=GitHub');\n```\n\n## License\n\nreact-native-url-polyfill is [MIT licensed](LICENSE).\n","funding_links":[],"categories":["Utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharpeni%2Freact-native-url-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharpeni%2Freact-native-url-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharpeni%2Freact-native-url-polyfill/lists"}