{"id":27850,"date":"2022-03-24T19:56:16","date_gmt":"2022-03-24T19:56:16","guid":{"rendered":"http:\/\/generate-qr-code-for-social-media-profiles"},"modified":"2022-03-24T19:56:16","modified_gmt":"2022-03-24T19:56:16","slug":"generate-qr-code-for-social-media-profiles","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/","title":{"rendered":"Generate QR Code for Social Media Profiles"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>QR (quick response) codes are a popular type of two-dimensional or matrix barcode that allows you to easily encode information in the form of machine-readable images. These images can be used anywhere, from websites and mobile apps to banners, brochures, flyers, and business cards. Its popularity and effectiveness can be attributed to several factors, including the ease with which it can be scanned from any angle with a simple camera the high level of data integrity it provides even when parts of the QR Code are damaged or dirty.<\/p>\n<p>The widespread use of QR codes has resulted in the development of several free and paid platforms for generating and scanning them. In this article, we will build a QR code generator that will encode alphanumeric data representing social media links. After that, we will add two additional features. The first is the ability to download the image locally. The second is to upload the resulting image to Cloudinary and receive a shareable URL that can be copied to the clipboard. This should be fun!<\/p>\n<p>Here is a <a href=\"https:\/\/codesandbox.io\/s\/generate-qr-code-8mt1lt\">link<\/a> to the demo on CodeSandbox.<\/p>\n<\/div>\n  \n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/generate-qr-code-8mt1lt?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"generate-qr-code-8mt1lt\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n  <div class=\"wp-block-cloudinary-markdown \"><h2>Project Setup<\/h2>\n<p>Run this command in your terminal to create a simple React application:<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">    npx create-react-app qr-code-generator\n<\/code><\/span><\/pre>\n<p>Next, run the following command in your terminal to install the dependencies we\u2019ll need for this project:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\">    <span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">i<\/span> <span class=\"hljs-selector-tag\">qrcode<\/span><span class=\"hljs-selector-class\">.react<\/span> <span class=\"hljs-selector-tag\">react-dropzone<\/span> <span class=\"hljs-selector-tag\">axios<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The <code>qrcode.react<\/code> module will generate the QR code. The <code>react-dropzone<\/code> module will be used to add Drag and drop functionality for the images embedded on the QR code, while the <code>**axios**<\/code> module will be the HTTP client.<\/p>\n<p>We\u2019ll also need to create a separate component (file picker) to handle the drag-and-drop for the images that will be embedded in our QR code. Run the following command at the root of your project to create a folder named <code>components<\/code> and a file inside called <code>ImagePicker.js<\/code>:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\">    <span class=\"hljs-selector-tag\">mkdir<\/span> <span class=\"hljs-selector-tag\">components<\/span>\n    <span class=\"hljs-selector-tag\">cd<\/span> <span class=\"hljs-selector-tag\">components<\/span>\n    <span class=\"hljs-selector-tag\">touch<\/span> <span class=\"hljs-selector-tag\">ImagePicker<\/span><span class=\"hljs-selector-class\">.js<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<h2>Render the Qr Code<\/h2>\n<p>Add the following to your <code>App.js<\/code> file:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    import '.\/styles.css';\n    import { useState } from 'react';\n    import QrCode from 'qrcode.react';\n    export default function App() {\n      const &#91;input, setInput] = useState('');\n      const uploadToCloudinary = async () =&gt; {};\n      const downloadImage = async () =&gt; {};\n      return (\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">main<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"form_group norm container\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Add link to social media profile<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span>\n              <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"url\"<\/span>\n              <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">{input}<\/span>\n              <span class=\"hljs-attr\">onChange<\/span>=<span class=\"hljs-string\">{(e)<\/span> =&gt;<\/span> setInput(e.target.value)}\n            \/&gt;\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n          {input &amp;&amp; (\n            <span class=\"hljs-tag\">&lt;&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">QrCode<\/span> <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">{input}<\/span> <span class=\"hljs-attr\">size<\/span>=<span class=\"hljs-string\">{400}<\/span> <span class=\"hljs-attr\">level<\/span>=<span class=\"hljs-string\">\"M\"<\/span> <span class=\"hljs-attr\">includeMargin<\/span> \/&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/&gt;<\/span>\n          )}\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">main<\/span>&gt;<\/span>\n      );\n    }\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In this component, we begin with some CSS, then some React hooks, and finally the <code>QrCode<\/code> component. We define a state variable called <code>input<\/code> in our <code>App<\/code> component, which will hold the URL of a random social media profile; this is followed by two other functions, <code>downloadImage<\/code> and <code>uploadToCloudinary<\/code>, which we will discuss later. Our <code>App<\/code> component renders several things; the first is an input field that updates the state variable with data provided by the user. We also conditionally render the <code>QrCode<\/code> component based on the availability of the user input, and it accepts the following props:<\/p>\n<ul>\n<li>\n<code>value<\/code>: the data that would be encoded in the QR code; this is fed the string stored in our input state variable.<\/li>\n<li>\n<code>size<\/code>: this number would represent the dimensions of the rendered image holding the QR code.<\/li>\n<li>\n<code>level<\/code>: the level prop represents the error correction level used. The value can be either low(\u201cL\u201d), medium(\u201cM\u201d), Quartile(\u201cQ\u201d), or high (\u201cH\u201d). Each value represents the error correction level used when generating the QR code. Higher values indicate better error correction. This would mean more data can be recovered even if the QR code gets damaged.<\/li>\n<li>\n<code>includeMargin<\/code>: it accepts a boolean value, which we set to <code>true<\/code>. This would allow some extra space to surround the generated symbol. This area is known as the silent zone in QR Code terminology because it helps the scanner identify where the barcode begins and ends.<\/li>\n<\/ul>\n<p>With this in place, you can run the application using the following command:<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">    npm start\n<\/code><\/span><\/pre>\n<p>In the running application, You should be able to add some text to the input field and see the resulting QR code generated.<\/p>\n<h2>Embed Logo in the QR Code<\/h2>\n<p>While plain QR code symbols are sufficient to decode any encoded information contained in them, for business and marketing needs which constitute one of the primary use for these symbols, adding a logo on your QR code provides you with several advantages. It demonstrates, aids in promoting your brand\u2019s identity and awareness, and so on.<\/p>\n<p>To embed images in our QR code, we will first create an image picker component that will be used to get our images. We will then use this component in our <code>App.js<\/code> file to select files and add them to the QR code.<\/p>\n<p>Add the following to your <code>ImagePicker.js<\/code> file:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">import<\/span> { useDropzone } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'react-dropzone'<\/span>;\n    <span class=\"hljs-keyword\">const<\/span> fileToB64 = <span class=\"hljs-function\">(<span class=\"hljs-params\">file<\/span>) =&gt;<\/span>\n      <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Promise<\/span>(<span class=\"hljs-function\">(<span class=\"hljs-params\">res, rej<\/span>) =&gt;<\/span> {\n        <span class=\"hljs-keyword\">const<\/span> fileReader = <span class=\"hljs-keyword\">new<\/span> FileReader();\n        fileReader.onload = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> res(fileReader.result);\n        fileReader.onerror = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> rej(fileReader.error);\n        fileReader.readAsDataURL(file);\n      });\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">ImagePicker<\/span>(<span class=\"hljs-params\">{ handleImageSelect, children }<\/span>) <\/span>{\n      <span class=\"hljs-keyword\">const<\/span> { getInputProps, getRootProps } = useDropzone({\n        <span class=\"hljs-attr\">maxFiles<\/span>: <span class=\"hljs-number\">1<\/span>,\n        <span class=\"hljs-attr\">accept<\/span>: <span class=\"hljs-string\">'image\/*'<\/span>,\n        <span class=\"hljs-attr\">onDrop<\/span>: <span class=\"hljs-keyword\">async<\/span> (arrayOfFiles) =&gt; {\n          <span class=\"hljs-keyword\">const<\/span> b64URL = <span class=\"hljs-keyword\">await<\/span> fileToB64(arrayOfFiles&#91;<span class=\"hljs-number\">0<\/span>]);\n          handleImageSelect(b64URL);\n        },\n      });\n      <span class=\"hljs-keyword\">return<\/span> (\n        <span class=\"xml\"><span class=\"hljs-tag\">&lt;&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> {<span class=\"hljs-attr\">...getRootProps<\/span>({ <span class=\"hljs-attr\">className:<\/span> '<span class=\"hljs-attr\">form_group<\/span>' })}&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span> {<span class=\"hljs-attr\">...getInputProps<\/span>()} \/&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">{<\/span>`<span class=\"hljs-attr\">bl<\/span>`}&gt;<\/span>Drag files to add image to QR code<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            {children}\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/&gt;<\/span><\/span>\n      );\n    }\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In this file, we start by bringing in the <code>useDropzone<\/code> hook provided by the <code>react-dropzone<\/code> module. Next, we define a helper function called <code>fileToB64<\/code>, which uses the <code>FileReader<\/code> API to return the Data URI of a Blob that gets passed as input.<\/p>\n<p>Next, we define the <code>ImagePicker<\/code> component, which accepts two props; the first is a function called <code>handleImageSelect<\/code> which would be used to feed the selected files to the parent component. Because we will use the <code>ImagePicker<\/code> component as a wrapper for other components, it also accepts the <code>children<\/code> prop. In the component body, we configure the options we want for the <code>Dropzone<\/code> by calling <code>useDropzone<\/code> and passing it an object representing the preferences we want. Here, we choose only to accept a single file which must be an image. We also define a handling function for the <code>onDrop<\/code> event that would fire whenever our <code>Dropzone<\/code> receives a file. It gets the file, converts it to a data URI and feeds it to the parent component using the <code>handleImageSelect<\/code> prop.<\/p>\n<p>The call to <code>useDropzone<\/code> returns an object containing the <code>Dropzone<\/code> state, and we extracted these three things from it:<\/p>\n<ul>\n<li>\n<code>getRootProps<\/code>: When called, this function would return an object representing the props for the Dropzone container, which can be any HTML element.<\/li>\n<li>\n<code>getInputProps<\/code>: this function holds the props for the input field, acting as the Decoy file picker for situations where the user decides to click on the Dropzone to pick files from their computer instead.<\/li>\n<\/ul>\n<p>Based on the information above, this component renders some JSX, including the <code>children<\/code> prop it receives and an <code>input<\/code> element. They are nested within the Dropzone with the required props passed to the Dropzone and input element, respectively.<\/p>\n<p>Next, let\u2019s use this component in our <code>App.js<\/code> file:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">import<\/span> ImagePicker <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'.\/components\/ImagePicker'<\/span>;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Next, let\u2019s create a variable that\u2019ll hold the content of our image.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-comment\">\/\/...<\/span>\n    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">App<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{\n      <span class=\"hljs-keyword\">const<\/span> &#91;input, setInput] = useState(<span class=\"hljs-string\">''<\/span>);\n      <span class=\"hljs-keyword\">const<\/span> &#91;image, setImage] = useState(<span class=\"hljs-string\">''<\/span>);\n    <span class=\"hljs-comment\">\/\/...<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Finally, we update the return statement of our <code>App<\/code> component like so.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    return (\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">main<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"form_group norm container\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>link to social media profile<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span>\n              <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"url\"<\/span>\n              <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">{input}<\/span>\n              <span class=\"hljs-attr\">onChange<\/span>=<span class=\"hljs-string\">{(e)<\/span> =&gt;<\/span> setInput(e.target.value)}\n            \/&gt;\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n          {input &amp;&amp; (\n            <span class=\"hljs-tag\">&lt;&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">section<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"dnd_con\"<\/span>&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ImagePicker<\/span>\n                  <span class=\"hljs-attr\">handleImageSelect<\/span>=<span class=\"hljs-string\">{(file)<\/span> =&gt;<\/span> {\n                    setImage(file);\n                  }}\n                &gt;\n                  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">QrCode<\/span>\n                    <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">{input}<\/span>\n                    <span class=\"hljs-attr\">size<\/span>=<span class=\"hljs-string\">{400}<\/span>\n                    <span class=\"hljs-attr\">imageSettings<\/span>=<span class=\"hljs-string\">{<\/span>\n                      <span class=\"hljs-attr\">image<\/span>\n                        ? {\n                            <span class=\"hljs-attr\">src:<\/span> <span class=\"hljs-attr\">image<\/span>,\n                            <span class=\"hljs-attr\">excavate:<\/span> <span class=\"hljs-attr\">true<\/span>,\n                            <span class=\"hljs-attr\">width:<\/span> <span class=\"hljs-attr\">82<\/span>,\n                            <span class=\"hljs-attr\">height:<\/span> <span class=\"hljs-attr\">82<\/span>,\n                          }\n                        <span class=\"hljs-attr\">:<\/span> {}\n                    }\n                    <span class=\"hljs-attr\">level<\/span>=<span class=\"hljs-string\">\"M\"<\/span>\n                    <span class=\"hljs-attr\">includeMargin<\/span>\n                  \/&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">ImagePicker<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">section<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/&gt;<\/span>\n          )}\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">main<\/span>&gt;<\/span>\n      );\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the return statement above, we used the <code>ImagePicker<\/code> component to wrap the <code>QrCode<\/code> component. <code>ImagePicker<\/code> accepts a function it uses to store the selected file in state. The <code>QrCode<\/code> component accepts an <code>ImageSettings<\/code> prop that holds an object defining the settings we want for the image that will be embedded. By default, the rendered image will be placed in the center, but you can also specify the coordinates if you want. In our case, we will go with the default coordinates.<\/p>\n<p>If you run your application now, you should be able to drag and drop images, as seen below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_36FF11C535FF0EFA6FCECBA376995D26625D2F239DD672C1A62BE9FA89BD6B93_1646238448436_CleanShot+2022-03-02+at+20.27.00.gif\" alt=\"\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"800\" height=\"355\"\/><\/p>\n<h2>Download QR Code<\/h2>\n<p>Update the <code>downloadImage<\/code> function in the <code>App<\/code> component like so:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">const<\/span> downloadImage = <span class=\"hljs-keyword\">async<\/span> (e) =&gt; {\n      <span class=\"hljs-keyword\">const<\/span> canvas = <span class=\"hljs-built_in\">document<\/span>.querySelector(<span class=\"hljs-string\">'canvas'<\/span>);\n      <span class=\"hljs-keyword\">const<\/span> imageDataURI = canvas.toDataURL(<span class=\"hljs-string\">'png'<\/span>, <span class=\"hljs-number\">1.0<\/span>);\n      <span class=\"hljs-keyword\">const<\/span> blob = <span class=\"hljs-keyword\">await<\/span> (<span class=\"hljs-keyword\">await<\/span> fetch(imageDataURI)).blob();\n      <span class=\"hljs-keyword\">const<\/span> URL = <span class=\"hljs-built_in\">window<\/span>.URL.createObjectURL(blob);\n      <span class=\"hljs-keyword\">const<\/span> el = <span class=\"hljs-built_in\">document<\/span>.createElement(<span class=\"hljs-string\">'a'<\/span>);\n      el.href = URL;\n      el.download = <span class=\"hljs-string\">'mydummyfile.png'<\/span>;\n      el.click();\n      <span class=\"hljs-built_in\">window<\/span>.URL.revokeObjectURL(URL);\n    };\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>This function starts by getting the <code>canvas<\/code> element in the DOM that renders the QR code and converts its contents to an image in the form of a Data URI. To make the Data URI downloadable, first, we transform it into a blob. Next, using the <code>createObjectURL<\/code> function, we create a string that references that blob in memory. This string is then passed as the <code>href<\/code> attribute to the anchor tag we created programmatically.<\/p>\n<p>To download the blob, we specified the download attribute on the anchor tag. Next, we click the anchor tag programmatically to download the image. The call to <code>window.URL.revokeObjectURL(URL)<\/code> clears the blobs reference string to avoid memory leaks. Now, let\u2019s update the return statement of our <code>App<\/code> component with a button that triggers the <code>dowloadImage<\/code> function.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">      return (\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">main<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"form_group norm container\"<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">label<\/span>&gt;<\/span>Add link to social media profile<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">label<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span>\n              <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"url\"<\/span>\n              <span class=\"hljs-attr\">value<\/span>=<span class=\"hljs-string\">{input}<\/span>\n              <span class=\"hljs-attr\">onChange<\/span>=<span class=\"hljs-string\">{(e)<\/span> =&gt;<\/span> setInput(e.target.value)}\n            \/&gt;\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n          {input &amp;&amp; (\n            <span class=\"hljs-tag\">&lt;&gt;<\/span>\n            \/\/...\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">section<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"btn_con\"<\/span>&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{downloadImage}<\/span>&gt;<\/span> download image<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">section<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/&gt;<\/span>\n          )}\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">main<\/span>&gt;<\/span>\n      );\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<h2>Generate QR Code Link<\/h2>\n<p>In this section, we will make use of the <a href=\"https:\/\/cloudinary.com\/\">Cloudinary<\/a> to store and manage media assets. We need to <a href=\"https:\/\/cloudinary.com\/users\/login?RelayState=%2Fconsole%2F%2F%3Fcustomer_external_id%3Dc-c346004e949c88da79ca13519f9ffb\">create an account<\/a> to store and manage media using Cloudinary. In the account details section on your dashboard, you should see your Credentials, as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_36FF11C535FF0EFA6FCECBA376995D26625D2F239DD672C1A62BE9FA89BD6B93_1646239642848_CleanShot+2022-03-02+at+20.46.312x.png\" alt=\"\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"718\"\/><\/p>\n<p>We will be sending images to Cloudinary via unsigned POST requests for this tutorial. To do this, we need our account cloud name and an unsigned <a href=\"https:\/\/cloudinary.com\/documentation\/upload_presets\">upload preset<\/a>. Specify a name for the upload preset and set the signing mode to unsigned; this will be sufficient for our app.<\/p>\n<h2>Upload Logic<\/h2>\n<p>Before updating the <code>uploadToCloudinary<\/code> function in the <code>App.js<\/code> file, we need to create a state to keep track of the loading state for uploading.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">App<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{\n      <span class=\"hljs-comment\">\/\/... other state variables<\/span>\n      <span class=\"hljs-keyword\">const<\/span> &#91;loading, setLoading] = useState(<span class=\"hljs-literal\">false<\/span>);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Now update the contents of the <code>uploadToCloudinary<\/code>  function to match the following:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">    <span class=\"hljs-keyword\">const<\/span> uploadAndGenSharableURL = <span class=\"hljs-keyword\">async<\/span> () =&gt; {\n      <span class=\"hljs-keyword\">const<\/span> canvas = <span class=\"hljs-built_in\">document<\/span>.querySelector(<span class=\"hljs-string\">'canvas'<\/span>);\n      <span class=\"hljs-keyword\">const<\/span> imageDataURI = <span class=\"hljs-keyword\">await<\/span> canvas.toDataURL(<span class=\"hljs-string\">'png'<\/span>, <span class=\"hljs-number\">1.0<\/span>);\n      <span class=\"hljs-keyword\">const<\/span> cloudname = <span class=\"hljs-string\">'INSERT-CLOUDNAME-HERE'<\/span>;\n      <span class=\"hljs-keyword\">const<\/span> upload_preset = <span class=\"hljs-string\">'INSERT-NAME-OF-UPLOAD-PRESET-HERE'<\/span>;\n      <span class=\"hljs-keyword\">try<\/span> {\n        setLoading(<span class=\"hljs-literal\">true<\/span>);\n        <span class=\"hljs-keyword\">let<\/span> res = <span class=\"hljs-keyword\">await<\/span> axios.post(\n          <span class=\"hljs-string\">`https:\/\/api.cloudinary.com\/v1_1\/<span class=\"hljs-subst\">${cloudname}<\/span>\/image\/upload`<\/span>,\n          {\n            <span class=\"hljs-attr\">file<\/span>: imageDataURI,\n            upload_preset,\n          }\n        );\n        <span class=\"hljs-keyword\">const<\/span> { url } = res.data;\n        <span class=\"hljs-keyword\">await<\/span> navigator.clipboard.writeText(url);\n        alert(<span class=\"hljs-string\">'COPIED TO CLIPBOARD'<\/span>);\n      } <span class=\"hljs-keyword\">catch<\/span> (error) {\n        <span class=\"hljs-built_in\">console<\/span>.log(error.message);\n      } <span class=\"hljs-keyword\">finally<\/span> {\n        setLoading(<span class=\"hljs-literal\">false<\/span>);\n      }\n    };\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In this function, we start by getting the Data URI from the <code>canvas<\/code> element that renders the QR code. Next, we define variables to store our cloud name and upload preset. After that, we attempt to upload the file by hitting the image upload Cloudinary endpoint and passing the request body, which holds the two compulsory fields when doing unsigned uploads. The <code>file<\/code> key contains the Data URI of our QR code, and the <code>upload_preset<\/code> key holds the string representing the upload preset we created earlier.<\/p>\n<p>If the API call is successful, we get a lot of things from the returned data, but what we are interested in is the <code>url<\/code> key that holds the URL pointing to the image on our Cloudinary account. Using the <code>clipboard.writeText<\/code> method, we copy the URL to the clipboard and notify the user. If the API call fails, we simply display an error message.<\/p>\n<p>Now, let\u2019s update our UI to include a button to trigger the <code>uploadToCloudinary<\/code>.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">    return (\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">main<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n        \/\/...\n    \n        {input &amp;&amp; (\n    \n          \/\/...\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">section<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"btn_con\"<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{downloadImage}<\/span>&gt;<\/span> download image<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{uploadToCloudinary}<\/span>&gt;<\/span>\n                {loading ? 'processing...' : 'copy QR code link'}\n              <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">section<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/&gt;<\/span>\n        )}\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">main<\/span>&gt;<\/span>\n    );\n    }\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>If we run our app now, we should be able to generate the QR codes with images embedded in them, download the resulting symbol, and get a sharable URL. You can also head over to the media gallery section of your Cloudinary dashboard to see the QR code image, as seen below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_36FF11C535FF0EFA6FCECBA376995D26625D2F239DD672C1A62BE9FA89BD6B93_1646242136381_CleanShot+2022-03-02+at+21.28.172x.png\" alt=\"\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"670\"\/><\/p>\n<p>Find the complete project <a href=\"https:\/\/github.com\/ifeoma-imoh\/generate-qr-codes\">here<\/a> on GitHub.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, we looked at how to build a QR code generator that encodes alphanumeric data representing social media links. This knowledge gives us a decent head start to explore the potential of this technology in future applications.<\/p>\n<p><strong>Resources you may find helpful:<\/strong><\/p>\n<ul>\n<li>\n<a href=\"https:\/\/www.npmjs.com\/package\/qrcode.react\">qrcode.react<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/react-dropzone.js.org\/\">react-dropzone documentation<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/QR_code\">QR code &#8211; Wikipedia<\/a>\n<\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":27851,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,370,246,371],"class_list":["post-27850","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-image","tag-react","tag-under-review"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Generate QR Code for Social Media Profiles<\/title>\n<meta name=\"description\" content=\"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Generate QR Code for Social Media Profiles\" \/>\n<meta property=\"og:description\" content=\"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-24T19:56:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Generate QR Code for Social Media Profiles\",\"datePublished\":\"2022-03-24T19:56:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\"},\"wordCount\":7,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA\",\"keywords\":[\"Guest Post\",\"Image\",\"React\",\"Under Review\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2022\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\",\"name\":\"Generate QR Code for Social Media Profiles\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA\",\"datePublished\":\"2022-03-24T19:56:16+00:00\",\"description\":\"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Generate QR Code for Social Media Profiles\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Generate QR Code for Social Media Profiles","description":"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/","og_locale":"en_US","og_type":"article","og_title":"Generate QR Code for Social Media Profiles","og_description":"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.","og_url":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/","og_site_name":"Cloudinary Blog","article_published_time":"2022-03-24T19:56:16+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/"},"author":{"name":"","@id":""},"headline":"Generate QR Code for Social Media Profiles","datePublished":"2022-03-24T19:56:16+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/"},"wordCount":7,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","keywords":["Guest Post","Image","React","Under Review"],"inLanguage":"en-US","copyrightYear":"2022","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/","url":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/","name":"Generate QR Code for Social Media Profiles","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","datePublished":"2022-03-24T19:56:16+00:00","description":"In this article, we will build a QR code generator that encodes alphanumeric data representing social media links.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/generate-qr-code-for-social-media-profiles\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Generate QR Code for Social Media Profiles"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681926109\/Web_Assets\/blog\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d\/6508e942d15c26397e755c0167c8a0c650dabf7e-1280x720-1_27851b0a3d.png?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/27850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=27850"}],"version-history":[{"count":0,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/27850\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/27851"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=27850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=27850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=27850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}