{"id":15407539,"url":"https://github.com/jarred-sumner/react-native-media-clipboard","last_synced_at":"2025-04-18T05:11:59.037Z","repository":{"id":38918257,"uuid":"240494448","full_name":"Jarred-Sumner/react-native-media-clipboard","owner":"Jarred-Sumner","description":"Image support for the clipboard in React Native","archived":false,"fork":false,"pushed_at":"2023-01-05T07:16:41.000Z","size":1597,"stargazers_count":51,"open_issues_count":15,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T22:15:08.094Z","etag":null,"topics":["clipboard","react","react-native","react-native-image"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C++","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/Jarred-Sumner.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}},"created_at":"2020-02-14T11:34:53.000Z","updated_at":"2024-02-29T22:33:09.000Z","dependencies_parsed_at":"2023-02-03T17:47:03.156Z","dependency_job_id":null,"html_url":"https://github.com/Jarred-Sumner/react-native-media-clipboard","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Freact-native-media-clipboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Freact-native-media-clipboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Freact-native-media-clipboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Freact-native-media-clipboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jarred-Sumner","download_url":"https://codeload.github.com/Jarred-Sumner/react-native-media-clipboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249433100,"owners_count":21271197,"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":["clipboard","react","react-native","react-native-image"],"created_at":"2024-10-01T16:29:02.654Z","updated_at":"2025-04-18T05:11:59.017Z","avatar_url":"https://github.com/Jarred-Sumner.png","language":"Objective-C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-native-media-clipboard\n\u003ca href=\"https://github.com/Jarred-Sumner/react-native-media-clipboard/blob/master/README.md#installation-ios-only\"\u003e\u003cimg height=200 src=\"https://user-images.githubusercontent.com/709451/74530526-1f6afc00-4edf-11ea-8706-f4273b80040e.png\" /\u003e\u003c/a\u003e\n\nReact Native has several libraries that let you get the contents of the clipboard, but none of them support images.\n\n`react-native-media-clipboard` suports:\n\n- images\n- strings\n- URLs\n\n## Getting started\n\n`$ npm install react-native-media-clipboard --save`\n\n### Installation (iOS only)\n\n1. `cd ios \u0026\u0026 pod install`\n2. Add the following line near the top of `AppDelegate.h`:\n\n```h\n#import \u003creact-native-media-clipboard/MediaClipboard.h\u003e\n```\n\n3. [Optional] Inside the AppDelegate `@implementation` add this:\n\n```objc\n- (void)applicationDidBecomeActive:(UIApplication *)application {\n  [MediaClipboard onApplicationBecomeActive];\n}\n```\n\n\u003csup\u003eThis makes sure that the clipboard is in sync if the application went into the background.\u003c/sup\u003e\n\n##### Swift bridging header\n\nIf your project does not contain any Swift code, then you need to create a bridging header – or you'll get a bunch of strange build errors.\n\n4. Xcode -\u003e File -\u003e New -\u003e Create an empty .swift file. It will prompt you asking if you want to create a bridging header. Say yes.\n\nIf your project already has Swift code (or a bridging header), just ignore this step.\n\n5. Re-build your app: `react-native run-ios`\n\n## Usage\n\n```javascript\nimport {\n  ClipboardContext,\n  ClipboardProvider\n} from \"react-native-media-clipboard\";\n```\n\n7. At the root of your application, add `\u003cClipboardProvider\u003e` in the render method, like this:\n\n```javascript\n\u003cClipboardProvider\u003e\n  \u003cMyVeryRealApp\u003e{children}\u003c/MyVeryRealApp\u003e\n\u003c/ClipboardProvider\u003e\n```\n\n8. `ClipboardContext` contains a `clipboard` and a `mediaSource` object. It automatically updates whenever the user copies something to their clipboard or removes something from their clipboard.\n\n```javascript\nconst { clipboard, mediaSource } = React.useContext(ClipboardContext);\n\n// Example mediaSource:\n{\n  \"mimeType\": \"image/png\",\n  \"scale\": 1,\n  \"width\": 828,\n  \"uri\": \"file:///tmp/C4A65610-E644-44C2-AC54-25A8AD56A4C6.png\",\n  \"height\": 1792\n}\n\n// Example clipboard:\n{\n  urls: [],\n  strings: [],\n  hasImages: false,\n  hasURLs: false,\n  hasStrings: false\n};\n\n// You can just pass in the `mediaSource` object to the built-in Image component. As long as the mediaSource object is not null, it should just work.\n\u003cImage source={mediaSource} /\u003e\n```\n\nThere are type definitions for these, so you shouldn't need to refer back to this much.\n\n---\n\nThis library is iOS only. There is no Android support.\n\nImages are saved in the temporary directory for the app in a background thread. It does not send `data` URIs across the bridge.\n\nThere is a JSI implementation of this as well, however I haven't finished porting it to this library. A contributor is welcome to submit a PR for that :)\n\n### Example repo\n\nExample repo: [react-native-media-clipboard-example](https://github.com/Jarred-Sumner/react-native-media-clipboard-example)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/709451/74530537-242fb000-4edf-11ea-913a-f5ae50be3601.png\"  height=400 /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarred-sumner%2Freact-native-media-clipboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjarred-sumner%2Freact-native-media-clipboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarred-sumner%2Freact-native-media-clipboard/lists"}