{"id":18421433,"url":"https://github.com/rebeloper/networkstate","last_synced_at":"2025-08-15T23:18:53.583Z","repository":{"id":169311186,"uuid":"331356467","full_name":"rebeloper/NetworkState","owner":"rebeloper","description":"Internet Connectivity for SwiftUI with NWPathMonitor","archived":false,"fork":false,"pushed_at":"2021-01-20T17:47:08.000Z","size":6,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T20:44:03.913Z","etag":null,"topics":["internet-connection-checker","internet-connectivity","internet-connectivity-status","internet-connectivity-swift","internet-connectivity-swiftui","reachability","reachability-swift","reachability-swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rebeloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-01-20T15:56:34.000Z","updated_at":"2024-03-19T18:40:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"27e4bb42-ff82-463c-bd0d-6051dea3215e","html_url":"https://github.com/rebeloper/NetworkState","commit_stats":null,"previous_names":["rebeloper/networkstate"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rebeloper/NetworkState","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FNetworkState","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FNetworkState/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FNetworkState/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FNetworkState/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rebeloper","download_url":"https://codeload.github.com/rebeloper/NetworkState/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rebeloper%2FNetworkState/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270644762,"owners_count":24621332,"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-15T02:00:12.559Z","response_time":110,"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":["internet-connection-checker","internet-connectivity","internet-connectivity-status","internet-connectivity-swift","internet-connectivity-swiftui","reachability","reachability-swift","reachability-swiftui"],"created_at":"2024-11-06T04:25:39.596Z","updated_at":"2025-08-15T23:18:53.562Z","avatar_url":"https://github.com/rebeloper.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🍬 NetworkState\n\n![swift v5.3](https://img.shields.io/badge/swift-v5.3-orange.svg)\n![platform iOS](https://img.shields.io/badge/platform-iOS-blue.svg)\n![deployment target iOS 13](https://img.shields.io/badge/deployment%20target-iOS%2013-blueviolet)\n\n**NetworkState** is a lightweight `Reachability/Internet Connection` library for `SwiftUI`.\n\n## 💻 Installation\n### 📦 Swift Package Manager\nUsing \u003ca href=\"https://swift.org/package-manager/\" rel=\"nofollow\"\u003eSwift Package Manager\u003c/a\u003e, add it as a Swift Package in Xcode 11.0 or later, `select File \u003e Swift Packages \u003e Add Package Dependency...` and add the repository URL:\n```\nhttps://github.com/rebeloper/NetworkState.git\n```\n### ✊ Manual Installation\nDownload and include the `NetworkState` folder and files in your codebase.\n\n### 📲 Requirements\n- iOS 13+\n- Swift 5.3+\n\n## 👉 Import\n\nImport `NetworkState` into your `View`\n\n```\nimport NetworkState\n```\n\n## 🧳 Features\n\nHere's the list of the awesome features `NetworkState` has:\n- [X] has a `@Published` `isOnline` variable to inspect\n- [X] access it as an `@EnvironmentObject` throughout your app\n- [X] easy to set up; easier to use\n\n## 💻 How to use\n\nFirst create a `NetworkState` object and add it as an `environmentObject` to your root `View`.\n\n```\nimport SwiftUI\nimport NetworkState\n\n@main\nstruct NetworkStateDemoApp: App {\n    \n    // 1.\n    let networkState = NetworkState()\n    \n    var body: some Scene {\n        WindowGroup {\n            // 2.\n            ContentView().environmentObject(networkState)\n        }\n    }\n}\n```\n\nGrab that `EnvironmentObject` (1.) and use the `isOnline` `@Published` variable (2.) to render out your UI. Optionally you could refres/check the connectivity with `isConnected()`. \n\n```\nimport SwiftUI\nimport NetworkState\n\nstruct ContentView: View {\n    \n    // 1.\n    @EnvironmentObject var networkState: NetworkState\n    \n    @State var isOnline = false\n    \n    var body: some View {\n        VStack(spacing: 12) {\n            // 2.\n            if networkState.isOnline {\n                Image(systemName: \"wifi\").font(.largeTitle)\n            } else {\n                Image(systemName: \"wifi.slash\").font(.largeTitle)\n            }\n            \n            // or \n            // Image(systemName: networkState.isOnline ? \"wifi\" : \"wifi.slash\").font(.largeTitle)\n            \n            // 3.\n            Button(action: {\n                if let isConnected = networkState.isConnected(), isConnected {\n                    isOnline = isConnected\n                } else {\n                    isOnline = false\n                }\n            }, label: {\n                Text(\"Refresh manually\")\n            })\n            \n            if isOnline {\n                Text(\"Showing this text only after we tapped the Button and if network is Connected\")\n            }\n            \n        }\n    }\n}\n```\n\n## 🪁 Demo project\n\nFor a comprehensive Demo project check out: \n\u003ca href=\"https://github.com/rebeloper/NetworkStateDemo\"\u003eNetworkStateDemo\u003c/a\u003e\n\n## ✍️ Contact\n\n\u003ca href=\"https://rebeloper.com/\"\u003erebeloper.com\u003c/a\u003e / \n\u003ca href=\"https://www.youtube.com/rebeloper/\"\u003eYouTube\u003c/a\u003e / \n\u003ca href=\"https://store.rebeloper.com/\"\u003eShop\u003c/a\u003e / \n\u003ca href=\"https://rebeloper.com/mentoring\"\u003eMentoring\u003c/a\u003e\n\n## 📃 License\n\nThe MIT License (MIT)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebeloper%2Fnetworkstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frebeloper%2Fnetworkstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frebeloper%2Fnetworkstate/lists"}