{"id":23719515,"url":"https://github.com/appfigures/react-easy-emoji","last_synced_at":"2025-04-06T07:11:15.203Z","repository":{"id":45784602,"uuid":"57332052","full_name":"appfigures/react-easy-emoji","owner":"appfigures","description":"Super minimal emoji rendering utility for react","archived":false,"fork":false,"pushed_at":"2024-06-16T10:40:40.000Z","size":250,"stargazers_count":101,"open_issues_count":1,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-28T01:55:33.825Z","etag":null,"topics":["emoji","react","react-component","twemoji"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/appfigures.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","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":"2016-04-28T20:34:46.000Z","updated_at":"2025-02-11T21:32:35.000Z","dependencies_parsed_at":"2024-06-18T13:55:11.236Z","dependency_job_id":"ec38c321-dea6-44a9-8df8-24098ee3110d","html_url":"https://github.com/appfigures/react-easy-emoji","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Freact-easy-emoji","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Freact-easy-emoji/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Freact-easy-emoji/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfigures%2Freact-easy-emoji/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfigures","download_url":"https://codeload.github.com/appfigures/react-easy-emoji/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445669,"owners_count":20939958,"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":["emoji","react","react-component","twemoji"],"created_at":"2024-12-30T21:52:20.310Z","updated_at":"2025-04-06T07:11:15.179Z","avatar_url":"https://github.com/appfigures.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Easy Emoji 🎉\n\n[![react-easy-emoji MIT license on NPM](https://img.shields.io/npm/l/react-easy-emoji.svg?style=flat-square)](https://www.npmjs.com/package/react-easy-emoji)\n[![react-easy-emoji on NPM](https://img.shields.io/npm/v/react-easy-emoji.svg)](https://www.npmjs.com/package/react-easy-emoji)\n[![Build Status](https://img.shields.io/circleci/project/appfigures/react-easy-emoji.svg)](https://circleci.com/gh/appfigures/react-easy-emoji)\n[![react-easy-emoji total downloads on NPM](https://img.shields.io/npm/dt/react-easy-emoji.svg?style=flat-square)](https://www.npmjs.com/package/react-easy-emoji)\n[![react-easy-emoji monthly downloads on NPM](https://img.shields.io/npm/dm/react-easy-emoji.svg?style=flat-square)](https://www.npmjs.com/package/react-easy-emoji)\n\nSuper minimal emoji rendering utility for React, with built in support for the wonderful [twemoji](https://github.com/twitter/twemoji) image set.\n\n\u003e We use Easy Emoji at Appfigures for rendering millions of [review cards](http://blog.appfigures.com/unleash-your-app-reviews-with-review-cards/).\n\n\u003ca href=\"https://appfigures.com/reviews/41680810438L1SidPd0I5JBQAxo-L2DlLQ\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/appfigures/react-easy-emoji/master/images/review-appfigures.png\" width=\"600\" /\u003e\n\u003c/a\u003e\n\n## Example\n\n**Basic usage**\n\n```\nimport emoji from 'react-easy-emoji'\n\nemoji('Emojis make me 😀')\n// output: ['Emojis make me ', \u003cimg src=\"//twemoji.maxcdn.com/2/72x72/1f604.png\" ... /\u003e]\n```\n\n**Rendering emojis in a component**\n\n```\nimport emoji from 'react-easy-emoji'\n\nclass Page extends React.Component {\n\trender () {\n\t\treturn \u003cp\u003e{ emoji('Emojis make me 😀') }\u003c/p\u003e\n\t}\n}\n```\n\n## Features\n\n- It's [tiny](https://bundlephobia.com/package/react-easy-emoji) (on purpose).\n- Simple functional API with minimal surface area and full customization hooks.\n- Lean implementation that follows the React way™ all the way down (no DOM manipulation).\n- Renders emoji from Twitter's Twemoji cdn out of the box.\n- Currently in use on high-traffic production pages.\n\n## What it doesn't do\n\nWe've consciously left out some extra features in order to keep this library as [minimal](https://en.wikipedia.org/wiki/Unix_philosophy) as possible:\n\n- Doesn't parse emoji names like `:smile:`.\n- Doesn't parse emoticons like `:)`.\n- Doesn't provide built-in support for emoji assets other than Twemoji, but provides hooks to use custom sets.\n\n## Installation\n\n```\nnpm install --save react-easy-emoji\n```\n\n## Common tasks\n\n### Using svg Twemoji assets instead of the default png\n\nReact Easy Emoji uses png assets from the Twemoji CDN by default. To use svg assets instead you can pass a few extra options:\n\n```\nfunction svgEmoji (input) {\n\treturn emoji(input, {\n\t\tbaseUrl: 'https://twemoji.maxcdn.com/2/svg/',\n\t\text: '.svg',\n\t\tsize: ''\n\t})\n}\n\n// example output: https://twemoji.maxcdn.com/2/svg/1f600.svg\n```\n\n### Using EmojiOne cdn assets instead of Twemoji\n\nWhile there's only built-in support for Twemoji assets, using assets from other libraries is extremely easy:\n\n```\nfunction emojiOne(input) {\n\treturn emoji(input, {\n\t\tbaseUrl: '//cdnjs.cloudflare.com/ajax/libs/emojione/2.2.5/assets/png/',\n\t\tsize: ''\n\t})\n}\n```\n\n### Rendering a custom React element instead of `\u003cimg\u003e`\n\nFor full control over how emojis get rendered just provide a function as the second parameter:\n\n```\nfunction customEmoji (input) {\n\treturn emoji(input, (code, string, key) =\u003e (\n\t\t\u003cMyEmoji code={ code } alt={ string } key={ key } /\u003e\n\t))\n}\n```\n\n## API Reference\n\n### `emoji(string|array[, options|renderFn]) =\u003e array`\n\nThis is the only function in this library. It allows for several different levels of customization\n\n#### Parameters\n\n`input: string | array`\n\nThe object to be emojified. Can be a simple string or an array which mixes react elements and strings. When an array is processed, all react elements are simply skipped but still get included in the output.\n\n**Array input example**\n\n```\nemoji(['simple string', \u003cbr /\u003e, 'string with emoji 🍻'])\n// Output: ['simple string', \u003cbr /\u003e, 'string with emoji ', \u003cimg src=\"//twemoji.maxcdn.com/...\" /\u003e]\n```\n\u003e Notice how the first two items in the array remain exactly the same, while the third gets split up.\n\n`options : object | renderFn : func`\n\nFor basic customization pass in an options object to specify how image urls are constructed. The following options are available:\n\n- `baseUrl : string` - Location of emoji images. Defaults to `//twemoji.maxcdn.com/2/`\n- `size : string` - Size of emojis images to use. Notice that this is the size of the base images, not the actual size the emoji will be rendered on the page. Defaults to `'72x72'`. For valid sizes to use with the Twemoji image set, please visit the [Twemoji project page](https://github.com/twitter/twemoji).\n- `ext : string` - File extension to be appended to the end of the url. Defaults to `.png`.\n- `protocol : string` - The url protocol of the image (either `http:` or `https:`). Defaults to the protocol of the current page to prevent mismatched protocol errors. To create a url with no protocol (ie. `//twemoji.maxcdn.com/...`) pass an empty string (`''`).\n- `props : object` - Additional props to merge into the `\u003cimg\u003e` jsx element. Defaults to `null`. Note that user provided props are applied last and may override any previous ones.\n\nFor complete control over the output emoji, pass a function instead of an options object, with the following signature:\n\n```\n(code, string, offset) =\u003e element : ReactElement\n```\n\n**Params**\n\n- `code : string` - The unicode value for the emoji. This is usually used to construct the source url.\n- `string : string` - The original string version of the emoji. This is usually used as the `alt` attribute to make copy and paste behave as expected.\n- `offset : number` - The zero-based position of the emoji in the original string. This is safe to use as the `key` attribute on the returned jsx element.\n\n**Return**\n\nThis function must return a valid React element. Since the output will be placed in an array it must have a `key` attribute. For more information on why a `key` attribute is required see the [React docs](https://facebook.github.io/react/docs/lists-and-keys.html#keys)\n\nExample:\n\n```\nemoji(string, (code, string, offset) =\u003e {\n\treturn \u003cMyEmoji code={ code } alt={ string } key={ offset } /\u003e\n})\n```\n\n## Inspiration\n\nWhile building [Appfigures Review Cards](http://blog.appfigures.com/unleash-your-app-reviews-with-review-cards/) we needed a simple emoji rendering library for React. We found several but none of them checked all of our boxes. The idealist in us wanted a library that doesn't pack any unnecessary features, doesn't manipulate the DOM, and has a functional API that does things the React way™. So with a little inspiration from [this thread](https://github.com/facebook/react/issues/3386) we decided to roll our own.\n\n## Other React emoji libraries\n\n- https://github.com/banyan/react-emoji\n- https://github.com/zxmys/react-twemoji\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfigures%2Freact-easy-emoji","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfigures%2Freact-easy-emoji","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfigures%2Freact-easy-emoji/lists"}