{"id":15914654,"url":"https://github.com/kirillpisarev/react-native-key-value-storage","last_synced_at":"2025-03-23T01:31:34.269Z","repository":{"id":57337921,"uuid":"103276965","full_name":"kirillpisarev/react-native-key-value-storage","owner":"kirillpisarev","description":null,"archived":false,"fork":false,"pushed_at":"2019-09-20T10:26:05.000Z","size":21,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-07T17:04:51.904Z","etag":null,"topics":["java","javascript","objective-c","react-native","sharedpreferences","userdefaults"],"latest_commit_sha":null,"homepage":null,"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/kirillpisarev.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":"2017-09-12T13:51:46.000Z","updated_at":"2019-11-14T12:19:12.000Z","dependencies_parsed_at":"2022-09-10T02:54:02.737Z","dependency_job_id":null,"html_url":"https://github.com/kirillpisarev/react-native-key-value-storage","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillpisarev%2Freact-native-key-value-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillpisarev%2Freact-native-key-value-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillpisarev%2Freact-native-key-value-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kirillpisarev%2Freact-native-key-value-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kirillpisarev","download_url":"https://codeload.github.com/kirillpisarev/react-native-key-value-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221841869,"owners_count":16890063,"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":["java","javascript","objective-c","react-native","sharedpreferences","userdefaults"],"created_at":"2024-10-06T17:05:01.296Z","updated_at":"2024-10-28T14:41:33.122Z","avatar_url":"https://github.com/kirillpisarev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Native Key Value Storage\n\nProvides an easy way to persistently store small chunks of data and then access it from the native code.\n\nApparent use case is to share settings between js part and long running tasks wrote on a native lang (services, background tasks etc).\n\nLibrary is built upon [SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences.html) on Android and on [UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults) on iOS.\n\n\nNote: currently supports only string values. To store other types use the JSON representation.\n\n### Usage\n\n##### JS\n\n``` js\nimport KeyValueStorage from \"react-native-key-value-storage\"\n\n(async () =\u003e {\n    try {\n        await KeyValueStorage.set(\"key\", \"value\")\n        const stored = await KeyValueStorage.get(\"key\") // \"value\"\n        await KeyValueStorage.remove(\"key\")\n    } catch(error) {\n        // Handle error\n    }\n})()\n\n```\n#### Java\n\n``` java\nimport com.mt.RNKeyValueStorage.KeyValueStorageModule;\n\nKeyValueStorageModule.set(\"key\", \"value\", context);\nKeyValueStorageModule.get(\"key\", context);\nKeyValueStorageModule.remove(\"key\", context);\n\n```\n#### Objective-c\n\n``` objective-c\n#import \"RNKeyValueStorage.h\"\n\n[KeyValueStorage setForKey:@\"key\" andValue:@\"value\"];\nNSString *stored = [KeyValueStorage getForKey:@\"key\"];\n[KeyValueStorage removeForKey:@\"key\"];\n\n```\n\n### Dependency\n\n- Use version `3.x.x` for RN `\u003e= 0.47.0`\n- Use version `1.x.x` for RN `\u003c 0.47.0`\n\n### Methods\n\n- `get(key: string) =\u003e Promise\u003cstring\u003e`\n\n- `set(key: string, value: string) =\u003e Promise\u003cvoid\u003e`\n\n- `remove(key: string) =\u003e Promise\u003cvoid\u003e`\n\n### Installation\n\n- In your project:\n```sh\n$ npm i react-native-key-value-storage -S\n\n```\n#### Link native code\n\n```sh\n$ react-native link react-native-key-value-storage\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirillpisarev%2Freact-native-key-value-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkirillpisarev%2Freact-native-key-value-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkirillpisarev%2Freact-native-key-value-storage/lists"}