{"componentChunkName":"component---src-templates-blog-list-template-js","path":"/engineering/11","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"excerpt":"When we develop a project in a react application, we encounter errors such as server-related errors, component/function errors, and so on…","fields":{"slug":"/engineering/react-error-boundaries/"},"html":"<p>When we develop a project in a react application, we encounter errors such as server-related errors, component/function errors, and so on, which break the application and result in a blank web page, which is not ideal. To resolve this, many methods are created that handle these errors and improve the user and developer experience.</p>\n<p>In React, Error Boundaries comes in the picture, which was introduced in React v16 that catch the javascript errors found in UI  and handle them efficiently. </p>\n<p>React Error Boundaries are React components that catch tricky javascript errors, log those errors and render them into a fallback UI instead of crashing the whole application.</p>\n<p>Now let's understand the concept with the code.</p>\n<h3 id=\"without-error-boundaries\" style=\"position:relative;\"><a href=\"#without-error-boundaries\" aria-label=\"without error boundaries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Without Error Boundaries</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">class</span><span class=\"mtk1\"> </span><span class=\"mtk10\">UpdateCount</span><span class=\"mtk1\"> </span><span class=\"mtk4\">extends</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Component</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk12\">state</span><span class=\"mtk1\"> = {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">count:</span><span class=\"mtk1\"> </span><span class=\"mtk7\">0</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  };</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">handleClick</span><span class=\"mtk1\"> = () </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk11\">setState</span><span class=\"mtk1\">({</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk12\">count:</span><span class=\"mtk1\"> </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">state</span><span class=\"mtk1\">.</span><span class=\"mtk12\">count</span><span class=\"mtk1\"> + </span><span class=\"mtk7\">1</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    });</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">render</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> {</span><span class=\"mtk12\">count</span><span class=\"mtk1\">} = </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">state</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">count</span><span class=\"mtk1\"> === </span><span class=\"mtk7\">4</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk3\">// Imitate an error!</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk15\">throw</span><span class=\"mtk1\"> </span><span class=\"mtk4\">new</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Error</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;Application crashed!&#39;</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">h1</span><span class=\"mtk17\">&gt;</span><span class=\"mtk4\">{</span><span class=\"mtk12\">count</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">h1</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">button</span><span class=\"mtk1\"> </span><span class=\"mtk12\">onClick</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">handleClick</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">+</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">};</span></span></code></pre>\n<p>When an application encounters an error, the component unmounts completely, leaving the user/developer with a blank web page and no idea what to do next.</p>\n<p>React Error Boundaries provides a method to handle these errors efficiently!</p>\n<h3 id=\"with-error-boundaries\" style=\"position:relative;\"><a href=\"#with-error-boundaries\" aria-label=\"with error boundaries permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>With Error Boundaries</h3>\n<p>First, let's make an error boundary component. Here is an example:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">class</span><span class=\"mtk1\"> </span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk1\"> </span><span class=\"mtk4\">extends</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Component</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk12\">state</span><span class=\"mtk1\"> = {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">error:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&#39;&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">static</span><span class=\"mtk1\"> </span><span class=\"mtk11\">getDerivedStateFromError</span><span class=\"mtk1\">(</span><span class=\"mtk12\">error</span><span class=\"mtk1\">) { </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk3\">// will update the state </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> {</span><span class=\"mtk12\">error:</span><span class=\"mtk1\"> </span><span class=\"mtk12\">error</span><span class=\"mtk1\">.</span><span class=\"mtk11\">toString</span><span class=\"mtk1\">()}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">render</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> {</span><span class=\"mtk12\">error</span><span class=\"mtk1\">} =  </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">state</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">error</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Looks like an error occurred!</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk4\">{</span><span class=\"mtk12\">error</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      )</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    return </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span><span class=\"mtk4\">{this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">props</span><span class=\"mtk1\">.</span><span class=\"mtk12\">children</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>In the above example code, you will see a static method <code>getDerivedStateFromError(error)</code>. This method is a lifecycle method in which we catch the error and see it as the state. If an error occurs, the state is updated, and instead of a blank web page, a human-friendly error message appears in rendering; if no error occurs, the control is returned to the original element.</p>\n<p>Now let’s see how we can use this <ErrorBoundary> class for our <UpdateCount> component.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">function</span><span class=\"mtk1\"> </span><span class=\"mtk11\">App</span><span class=\"mtk1\">() {  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;&lt;</span><span class=\"mtk4\">b</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Error Boundary Example code</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">b</span><span class=\"mtk17\">&gt;&lt;/</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">hr</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Two updatecounts component use same error boundary component.</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">UpdateCount</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">UpdateCount</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">hr</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Two updatecounts component use their own error boundary component.</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">p</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;&lt;</span><span class=\"mtk10\">UpdateCount</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;&lt;/</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;&lt;</span><span class=\"mtk10\">UpdateCount</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;&lt;/</span><span class=\"mtk10\">ErrorBoundary</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}  </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk12\">App</span><span class=\"mtk1\"> </span></span></code></pre>\n<p>In the above code, when we click on the plus (+) button, it increases the count. The program is programmed to throw an error when the count reaches 4. It simulates a JavaScript error in a component. Here, we have used the error boundary in two ways, which are given below.</p>\n<p>First, these two updatecounts are within the same error boundary. If one of the updateCount components crashes, then the error boundary will replace them both.\nSecond, these two updatecounts are within their individual error limits. So if one crashes, the other component is not affected because both have their own error boundary component.</p>\n<p>React Error boundary is a really nice feature in React, and it is comparatively less used.\nThere are a lot of nice error boundary packages out there; you should look into them.  Here is a link  <a href=\"https://github.com/bvaughn/react-error-boundary#readme\">react-error-boundary</a></p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk17 { color: #808080; }\n</style>","frontmatter":{"date":"May 20, 2021","updated_date":null,"description":"Error Handling in React using React Error Boundaries","title":"React Error Boundaries","tags":["React","Error Handling","JavaScript"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/95277564493241e87bee30b1a4197e71/ee604/error_boundary_cover.png","srcSet":"/static/95277564493241e87bee30b1a4197e71/69585/error_boundary_cover.png 200w,\n/static/95277564493241e87bee30b1a4197e71/497c6/error_boundary_cover.png 400w,\n/static/95277564493241e87bee30b1a4197e71/ee604/error_boundary_cover.png 800w,\n/static/95277564493241e87bee30b1a4197e71/f3583/error_boundary_cover.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Versha Gupta","github":"vershagupta","avatar":null}}}},{"node":{"excerpt":"There are several Consumer/User data protection regulations in place to protect customer data and privacy. With data protection act like the…","fields":{"slug":"/engineering/user-privacy-data-masking-in-nginx-logs/"},"html":"<p>There are several Consumer/User data protection regulations in place to protect customer data and privacy. With data protection act like the California Consumer Privacy Act (CCPA) and the European Union's GDPR improving awareness of privacy rights, many data-driven businesses have sought to determine which of their applications contain sensitive data, where the sensitive data goes, and why data is going. As a result, they are re-evaluating their data protection controls for employee and consumer data.</p>\n<p> Your program must record vast volumes of data to meet business requirements. It's likely that the application log data contains highly sensitive information. Email addresses, URL parameters such as tokens, credit card data, jobs data, Login Credentials, and Official ID Numbers (passport numbers, driver's license numbers, social security numbers), and authentication tokens may be included in specific log messages. It is important to mask sensitive details such as authentication tokens or credit card info while logging.</p>\n<p> A few years ago, Twitter requested users to reset their passwords. According to <a href=\"https://blog.twitter.com/official/en_us/topics/company/2018/keeping-your-account-secure.html\">Twitter's release</a>, passwords were written in the logs without masking, allowing those with access to the logs to see the password. In most startups or small businesses, all staff members have access to all tools, so masking confidential data is critical. Most log management tools allow you to mask any information until it is saved in the logs. Most of the log monitoring tools provide the feature for masking any information before it will save in the logs.</p>\n<h3 id=\"masking-sensitive-data-in-nginx-logs\" style=\"position:relative;\"><a href=\"#masking-sensitive-data-in-nginx-logs\" aria-label=\"masking sensitive data in nginx logs permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Masking Sensitive Data in Nginx Logs</h3>\n<p> By default, Nginx logs predefined format is combined. As you know, we can overwrite access log formatting as per the requirement. The NGINX JavaScript plugin can be used to enforce data masking in NGINX logs. This module is a kind of JavaScript implementation for NGINX and NGINX Plus that is intended for server-side use cases and per-request processing. When each request is logged, we run a small amount of JavaScript code to masking the sensitive data.</p>\n<h3 id=\"instructions-for-enabling-the-nginx-javascript-module\" style=\"position:relative;\"><a href=\"#instructions-for-enabling-the-nginx-javascript-module\" aria-label=\"instructions for enabling the nginx javascript module permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Instructions for enabling the NGINX JavaScript module</h3>\n<p> The NGINX JavaScript module is by default included in the official NGINX Docker image. if your installed version is 1.9.11 or later, then you can install NGINX JavaScript as a prebuilt package for your platform</p>\n<ol>\n<li>\n<p>Install the prebuilt package.</p>\n<p>Ubuntu and Debian systems</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk12\">$</span><span class=\"mtk1\"> </span><span class=\"mtk12\">sudo</span><span class=\"mtk1\"> </span><span class=\"mtk12\">apt</span><span class=\"mtk1\">-</span><span class=\"mtk12\">get</span><span class=\"mtk1\"> </span><span class=\"mtk12\">install</span><span class=\"mtk1\"> </span><span class=\"mtk12\">nginx</span><span class=\"mtk1\">-</span><span class=\"mtk10\">module</span><span class=\"mtk1\">-</span><span class=\"mtk12\">njs</span></span></code></pre>\n<p>RedHat, CentOS, and Oracle Linux systems</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk12\">$</span><span class=\"mtk1\"> </span><span class=\"mtk12\">sudo</span><span class=\"mtk1\"> </span><span class=\"mtk12\">yum</span><span class=\"mtk1\"> </span><span class=\"mtk12\">install</span><span class=\"mtk1\"> </span><span class=\"mtk12\">nginx</span><span class=\"mtk1\">-</span><span class=\"mtk10\">module</span><span class=\"mtk1\">-</span><span class=\"mtk12\">njs</span></span></code></pre>\n</li>\n<li>\n<p>Enable the module by adding a load module directive in the nginx.conf</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk12\">load_module</span><span class=\"mtk1\"> </span><span class=\"mtk12\">modules</span><span class=\"mtk1\">/</span><span class=\"mtk12\">ngx_http_js_module</span><span class=\"mtk1\">.</span><span class=\"mtk12\">so</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk12\">load_module</span><span class=\"mtk1\"> </span><span class=\"mtk12\">modules</span><span class=\"mtk1\">/</span><span class=\"mtk12\">ngx_stream_js_module</span><span class=\"mtk1\">.</span><span class=\"mtk12\">so</span><span class=\"mtk1\">;</span></span></code></pre>\n</li>\n<li>\n<p>Reload NGINX service</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">sudo</span><span class=\"mtk1\"> </span><span class=\"mtk12\">nginx</span><span class=\"mtk1\"> -</span><span class=\"mtk12\">s</span><span class=\"mtk1\"> </span><span class=\"mtk12\">reload</span></span></code></pre>\n</li>\n</ol>\n<h3 id=\"how-to-mask-query-string-in-nginx-and-nginx-plus\" style=\"position:relative;\"><a href=\"#how-to-mask-query-string-in-nginx-and-nginx-plus\" aria-label=\"how to mask query string in nginx and nginx plus permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to mask Query String in NGINX and NGINX Plus</h3>\n<p> An application can be passed some potentially confidential information as query string parameters like tokens, public key, etc., this information logged as part of the request URI. If your program sends personal information in this manner, you can use the NGINX JavaScript module for masking customer/user personal information in the query string.</p>\n<ol>\n<li>\n<p>Create a new file <code>maskQueryString.js</code></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk12\">vi</span><span class=\"mtk1\"> </span><span class=\"mtk12\">maskQueryString</span><span class=\"mtk1\">.</span><span class=\"mtk12\">js</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk4\">function</span><span class=\"mtk1\"> </span><span class=\"mtk11\">fnv32a</span><span class=\"mtk1\">(</span><span class=\"mtk12\">str</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">2166136261</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">       </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> (</span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">i</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0</span><span class=\"mtk1\">; </span><span class=\"mtk12\">i</span><span class=\"mtk1\"> &lt; </span><span class=\"mtk12\">str</span><span class=\"mtk1\">.</span><span class=\"mtk12\">length</span><span class=\"mtk1\">; ++</span><span class=\"mtk12\">i</span><span class=\"mtk1\"> ) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">           </span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> ^= </span><span class=\"mtk12\">str</span><span class=\"mtk1\">.</span><span class=\"mtk11\">charCodeAt</span><span class=\"mtk1\">(</span><span class=\"mtk12\">i</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">           </span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> += (</span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &lt;&lt; </span><span class=\"mtk7\">1</span><span class=\"mtk1\">) + (</span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &lt;&lt; </span><span class=\"mtk7\">4</span><span class=\"mtk1\">) + (</span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &lt;&lt; </span><span class=\"mtk7\">7</span><span class=\"mtk1\">) + (</span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &lt;&lt; </span><span class=\"mtk7\">8</span><span class=\"mtk1\">) + (</span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &lt;&lt; </span><span class=\"mtk7\">24</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">       }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">       </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> </span><span class=\"mtk12\">hval</span><span class=\"mtk1\"> &gt;&gt;&gt; </span><span class=\"mtk7\">0</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   }</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk4\">function</span><span class=\"mtk1\"> </span><span class=\"mtk11\">maskQueryStringParameters</span><span class=\"mtk1\">(</span><span class=\"mtk12\">req</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">query_string</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">req</span><span class=\"mtk1\">.</span><span class=\"mtk12\">variables</span><span class=\"mtk1\">.</span><span class=\"mtk12\">query_string</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">query_string</span><span class=\"mtk1\">.</span><span class=\"mtk12\">length</span><span class=\"mtk1\">) {                     </span><span class=\"mtk3\">// Proceed if we have query string</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">       </span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">query_string</span><span class=\"mtk1\">.</span><span class=\"mtk11\">split</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;&&#39;</span><span class=\"mtk1\">);     </span><span class=\"mtk3\">// Convert to array of key=value</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">           </span><span class=\"mtk15\">for</span><span class=\"mtk1\"> (</span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">i</span><span class=\"mtk1\"> = </span><span class=\"mtk7\">0</span><span class=\"mtk1\">; </span><span class=\"mtk12\">i</span><span class=\"mtk1\"> &lt; </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">.</span><span class=\"mtk12\">length</span><span class=\"mtk1\">; </span><span class=\"mtk12\">i</span><span class=\"mtk1\">++) { </span><span class=\"mtk3\">// Iterate through each Key Value pairs pair</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk12\">i</span><span class=\"mtk1\">].</span><span class=\"mtk11\">split</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;=&#39;</span><span class=\"mtk1\">);    </span><span class=\"mtk3\">// Split Key Value pair into new array</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] == </span><span class=\"mtk8\">&quot;token&quot;</span><span class=\"mtk1\">) {              </span><span class=\"mtk3\">// Mask token query paramter</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk3\">// Use first 5 digits of masked value</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk12\">kvpairs</span><span class=\"mtk1\">[</span><span class=\"mtk12\">i</span><span class=\"mtk1\">] = </span><span class=\"mtk12\">kvpair</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] + </span><span class=\"mtk8\">&quot;=&quot;</span><span class=\"mtk1\"> + </span><span class=\"mtk11\">fnv32a</span><span class=\"mtk1\">(</span><span class=\"mtk12\">kvpair</span><span class=\"mtk1\">[</span><span class=\"mtk7\">1</span><span class=\"mtk1\">]).</span><span class=\"mtk11\">toString</span><span class=\"mtk1\">().</span><span class=\"mtk11\">substr</span><span class=\"mtk1\">(</span><span class=\"mtk7\">5</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               } </span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk12\">ekse</span><span class=\"mtk1\"> </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] == </span><span class=\"mtk8\">&quot;accountno&quot;</span><span class=\"mtk1\">) {              </span><span class=\"mtk3\">// Mask account no</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk3\">// Use first 7 digits of masked value</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk12\">i</span><span class=\"mtk1\">] = </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] + </span><span class=\"mtk8\">&quot;=&quot;</span><span class=\"mtk1\"> + </span><span class=\"mtk11\">fnv32a</span><span class=\"mtk1\">(</span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">1</span><span class=\"mtk1\">]).</span><span class=\"mtk11\">toString</span><span class=\"mtk1\">().</span><span class=\"mtk11\">substr</span><span class=\"mtk1\">(</span><span class=\"mtk7\">0</span><span class=\"mtk1\">,</span><span class=\"mtk7\">7</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               } </span><span class=\"mtk15\">else</span><span class=\"mtk1\"> </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] == </span><span class=\"mtk8\">&quot;email&quot;</span><span class=\"mtk1\">) {     </span><span class=\"mtk3\">// Mask email</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk3\">// Use hash as prefix for a single domain</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">               </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk12\">i</span><span class=\"mtk1\">] = </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">0</span><span class=\"mtk1\">] + </span><span class=\"mtk8\">&quot;=&quot;</span><span class=\"mtk1\"> + </span><span class=\"mtk11\">fnv32a</span><span class=\"mtk1\">(</span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">[</span><span class=\"mtk7\">1</span><span class=\"mtk1\">]) + </span><span class=\"mtk8\">&quot;@sample.com&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">           }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">   </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> </span><span class=\"mtk12\">req</span><span class=\"mtk1\">.</span><span class=\"mtk12\">uri</span><span class=\"mtk1\"> + </span><span class=\"mtk8\">&quot;?&quot;</span><span class=\"mtk1\"> + </span><span class=\"mtk12\">keyvaluepairs</span><span class=\"mtk1\">.</span><span class=\"mtk11\">join</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;&&#39;</span><span class=\"mtk1\">);  </span><span class=\"mtk3\">// Construct masked URI</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">return</span><span class=\"mtk1\"> </span><span class=\"mtk12\">req</span><span class=\"mtk1\">.</span><span class=\"mtk12\">uri</span><span class=\"mtk1\">; </span><span class=\"mtk3\">// No query string, return URI</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<p>The maskQueryStringParameters function loops through and key-value pair in the query string, searching for individual keys that have been identified as containing personal data. The value is converted into a masked value for each of these keys.</p>\n</li>\n<li>Include <code>maskQueryString.js</code> file in the <code>nginx.config</code> file </li>\n</ol>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">     </span><span class=\"mtk12\">http</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk12\">js_include</span><span class=\"mtk1\"> </span><span class=\"mtk12\">maskQueryString</span><span class=\"mtk1\">.</span><span class=\"mtk12\">js</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk12\">js_set</span><span class=\"mtk1\">     </span><span class=\"mtk12\">$request_uri_masked</span><span class=\"mtk1\"> </span><span class=\"mtk12\">maskQueryStringParameters</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk12\">log_format</span><span class=\"mtk1\"> </span><span class=\"mtk12\">custom_log_format</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&#39;$remote_addr - $remote_user [$time_local] &#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">                        </span><span class=\"mtk8\">&#39;&quot;$request&quot; $status $body_bytes_sent $request_uri_masked &#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">                        </span><span class=\"mtk8\">&#39;&quot;$http_host&quot; &quot;$upstream_response_time&quot;&#39;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">                         </span><span class=\"mtk8\">&#39;&quot;$http_referer&quot; &quot;$http_user_agent&quot; clientId=&quot;$clientid&quot;&#39;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk12\">access_log</span><span class=\"mtk1\"> /</span><span class=\"mtk12\">spool</span><span class=\"mtk1\">/</span><span class=\"mtk12\">logs</span><span class=\"mtk1\">/</span><span class=\"mtk12\">nginx</span><span class=\"mtk1\">-</span><span class=\"mtk12\">access</span><span class=\"mtk1\">.</span><span class=\"mtk12\">log</span><span class=\"mtk1\"> </span><span class=\"mtk12\">custom_log_format</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">....................</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span></code></pre>\n<p> In the above example, I am using the <code>maskQueryStringParameters</code> js function and Since we only need to mask the query string, so using a different variable $request<em>uri</em>masked and then using the same variable in the log format. </p>\n<p>3.Reload NGINX service</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"javascript\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk12\">sudo</span><span class=\"mtk1\"> </span><span class=\"mtk12\">nginx</span><span class=\"mtk1\"> -</span><span class=\"mtk12\">s</span><span class=\"mtk1\"> </span><span class=\"mtk12\">reload</span></span></code></pre>\n<p> Now nginx will store <code>token</code>, <code>accountno</code>,  and <code>email</code> in the logs after sanitizing the data. </p>\n<h3 id=\"summery\" style=\"position:relative;\"><a href=\"#summery\" aria-label=\"summery permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summery</h3>\n<p>These best practices will help you keep confidential information out of your logs. It's not a full package that will get you ready for a HIPAA or SOC2 audit, but it'll get you started.</p>\n<p>The NGINX JavaScript module provides a quick and efficient approach for adding custom logic like data sanitizing to request processing. I showed how NGINX JavaScript could be used to mask personal data in the log files.</p>\n<p>You can get more detail about the Nginx logs and mask from here -\n<a href=\"https://www.loginradius.com/blog/engineering/user-privacy-data-masking-in-nginx-logs/\">Nginx - Everything you want to know about the Nginx logs in 10 minutes</a></p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n</style>","frontmatter":{"date":"May 18, 2021","updated_date":null,"description":"Learn about data masking in nginx logs for user data privacy and compliance.","title":"Data Masking In Nginx Logs For User Data Privacy And Compliance","tags":["Nginx","Logs","Data Masking","Compliance","Privacy"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.3333333333333333,"src":"/static/5d13afa8ca711b40eb6527325a97adb1/f422e/data-masking-in-nginx-logs-for-user-data-privacy-and-compliance.jpg","srcSet":"/static/5d13afa8ca711b40eb6527325a97adb1/f836f/data-masking-in-nginx-logs-for-user-data-privacy-and-compliance.jpg 200w,\n/static/5d13afa8ca711b40eb6527325a97adb1/2244e/data-masking-in-nginx-logs-for-user-data-privacy-and-compliance.jpg 400w,\n/static/5d13afa8ca711b40eb6527325a97adb1/f422e/data-masking-in-nginx-logs-for-user-data-privacy-and-compliance.jpg 640w","sizes":"(max-width: 640px) 100vw, 640px"}}},"author":{"id":"Vijay Singh Shekhawat","github":"code-vj","avatar":null}}}},{"node":{"excerpt":"Everyone wants their application so fast, but how to achieve that, in that case, code splitting comes into the picture, where we split code…","fields":{"slug":"/engineering/react-code-splitting-with-lazy-suspense/"},"html":"<p>Everyone wants their application so fast, but how to achieve that, in that case, <strong>code splitting</strong> comes into the picture, where we split code and set the priority loading of the code snippet.</p>\n<p>But how do we set the priority or load them whenever required?</p>\n<h2 id=\"1-reactlazy\" style=\"position:relative;\"><a href=\"#1-reactlazy\" aria-label=\"1 reactlazy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. React.lazy()</h2>\n<p>Using this we can set code priority to the lower or it will load only whenever required. So how to do that? it's easy, let's understand through an example.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk3\">//generally approach to import Component</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\"> </span><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">Blog</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&#39;./BlogComponent&#39;</span><span class=\"mtk1\">;</span></span></code></pre>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">// This component is loaded dynamically or lazy load</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk12\">BlogComponent</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">React</span><span class=\"mtk1\">.</span><span class=\"mtk11\">lazy</span><span class=\"mtk1\">(() </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> </span><span class=\"mtk4\">import</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;./BlogComponent&#39;</span><span class=\"mtk1\">));</span></span></code></pre>\n<h2 id=\"2-reactsuspense\" style=\"position:relative;\"><a href=\"#2-reactsuspense\" aria-label=\"2 reactsuspense permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. React.Suspense()</h2>\n<p>Once the component is set for a lazy load then we need to set some kind of fallback option as well, till that code is rendered. This fallback option either could be a loader icon, screen, image, etc.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk3\">// This component is loaded dynamically or lazy load</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk12\">BlogComponent</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">React</span><span class=\"mtk1\">.</span><span class=\"mtk11\">lazy</span><span class=\"mtk1\">(() </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> </span><span class=\"mtk4\">import</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&#39;./BlogComponent&#39;</span><span class=\"mtk1\">));</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">function</span><span class=\"mtk1\"> </span><span class=\"mtk11\">AppComponent</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk3\">// Displays &lt;LoaderSpinner&gt; until BlogComponent loads</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">React.Suspense</span><span class=\"mtk1\"> </span><span class=\"mtk12\">fallback</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">LoaderSpinner</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">BlogComponent</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">React.Suspense</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span></code></pre>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk17 { color: #808080; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n</style>","frontmatter":{"date":"May 13, 2021","updated_date":null,"description":"Load Application faster with code spliting and dynamic loading","title":"Code spliting in React via lazy and suspense","tags":["React"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/12ea532cdd9f0017a02bfb74d888bba7/ee604/react.png","srcSet":"/static/12ea532cdd9f0017a02bfb74d888bba7/69585/react.png 200w,\n/static/12ea532cdd9f0017a02bfb74d888bba7/497c6/react.png 400w,\n/static/12ea532cdd9f0017a02bfb74d888bba7/ee604/react.png 800w,\n/static/12ea532cdd9f0017a02bfb74d888bba7/f3583/react.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Abhimanyu Singh Rathore","github":"abhir9","avatar":null}}}},{"node":{"excerpt":"Hey Everyone !!! This blog will walk you through the steps necessary to quickly implement authentication mechanisms for your React…","fields":{"slug":"/engineering/implement-authentication-in-react-using-loginradius-cli/"},"html":"<p>Hey Everyone !!! This blog will walk you through the steps necessary to quickly implement authentication mechanisms for your React application by leveraging <a href=\"https://accounts.loginradius.com/auth.aspx?return_url=https://dashboard.loginradius.com/login\">LoginRadius</a> and the <a href=\"https://github.com/LoginRadius/lr-cli\">LoginRadius CLI</a> with the help of examples. </p>\n<p>Using the LoginRadius CLI, you can perform basic actions of your LoginRadius Dashboard through the command line. The actions include login, register, logout, social configuration, domain whitelisting, site management, etc. Once the actions are performed, changes will be reflected in your application. </p>\n<h2 id=\"configuring-loginradius\" style=\"position:relative;\"><a href=\"#configuring-loginradius\" aria-label=\"configuring loginradius permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuring LoginRadius</h2>\n<p>Please follow the steps below to install the LoginRadius CLI on your system. Once completed, use the CLI to finish registration on the LoginRadius portal and create your application. </p>\n<h3 id=\"loginradius-cli-setup\" style=\"position:relative;\"><a href=\"#loginradius-cli-setup\" aria-label=\"loginradius cli setup permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>LoginRadius CLI Setup</h3>\n<h4 id=\"mac-or-linux\" style=\"position:relative;\"><a href=\"#mac-or-linux\" aria-label=\"mac or linux permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mac or Linux</h4>\n<ul>\n<li>\n<p>Install the tap using:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"sh\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">$ brew tap loginradius/tap</span></span></code></pre>\n</li>\n<li>\n<p>Then, you can install LR CLI via:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"sh\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">$ brew install lr</span></span></code></pre>\n</li>\n</ul>\n<h4 id=\"other-platforms\" style=\"position:relative;\"><a href=\"#other-platforms\" aria-label=\"other platforms permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Other Platforms</h4>\n<ul>\n<li>Packaged binaries are available on the <a href=\"https://github.com/loginradius/lr-cli/releases/latest\">release page</a>.</li>\n</ul>\n<p>Once you have the CLI installed, the following command can be used to complete the registration process via the LoginRadius portal. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"sh\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">$ lr register</span></span></code></pre>\n<p>This command will open the Portal in the browser, where you can register yourself and create the app.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 56.30769230769231%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABPUlEQVQoz62SzUrDQBSFZ5E0av3BheDCQsHWpMWNtCCaNCm4EARBcCGu3IqP6YskgUBFJFqsJm0mOc5ME5xQIxa8cLhnJszHuZeQzY6FDcPEVncA4fW5V5p9WFd3cD0PHpPresLLKu5938do9IQgCEDUtgm1bUFp8T73mj4A2ethePuAZYtoBwxQkolVgwEbPTg390jTVIhSiizL2JNM9OJeFmUSQLV1CmX/BDWWkJ8FkCdkQLlmSYKPKEIUT3M4FjqpMdj64Rm2j86hGUMBrQJ+RjFewlc8h28szTeo8I/eGIQn2+lfoGlfY/f4EvWugxW+w0a/BCwS8NEmk3ckCRVejJ9/c8P47yPzhyINTRFPZ2KnBbA8cg6RVQWsKhkqEnKorN8S/qSFhHxn9Y6DNSZNtxnQXiph6T/8b+AXX52JrLgCSCEAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Register Page\"\n        src=\"/static/6b5302923e16cbb46586e327f58d68ed/e5715/register_page.png\"\n        srcset=\"/static/6b5302923e16cbb46586e327f58d68ed/a6d36/register_page.png 650w,\n/static/6b5302923e16cbb46586e327f58d68ed/e5715/register_page.png 768w,\n/static/6b5302923e16cbb46586e327f58d68ed/29114/register_page.png 1920w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span></p>\n<p>If you already have a LoginRadius account, use the command below to directly login :</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"sh\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">$ lr login</span></span></code></pre>\n<p>Once you successfully register or login, the below message will be visible in a new tab on the browser. Close the tab and return to the CLI. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">You are Successfully Authenticated, Kindly Close this browser window and go back to CLI.</span></code></pre>\n<p>If your account has multiple sites (for Developer/Developer Pro Plans), an option will be given to choose the site that you wish to login with. You can choose a site according to your preference.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"sh\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk1\">$ lr login</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  Successfully Authenticated, Fetching Your Site(s)...</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">? Current Site is: &lt;value&gt;, Want to Switch? Yes</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">? Select the site from the list: &lt;value&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  Site has been updated.</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  Successfully Logged In</span></span></code></pre>\n<h3 id=\"fetching-application-api-credentials\" style=\"position:relative;\"><a href=\"#fetching-application-api-credentials\" aria-label=\"fetching application api credentials permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Fetching Application API Credentials</h3>\n<p>Once the <strong>login/register</strong> process has been completed, run the <code>lr get config</code> command to fetch your <strong>API Key/Secret</strong> as shown below. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 37.53846153846154%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAABYlAAAWJQFJUiTwAAAA5UlEQVQoz6XQX2vCMBAA8EuatDRdm/6xFpk+us+253XfY+973/w8gogPYsdqeiqbn2EXaMGB8cXAj7uQy3EJSClfLACorxFC1Eqp1zAMa8557agb7j9DEAQn0tJmf43v+ybLMtRao+d5xlVH7NkGgLOGki0w1nBf2NzaOTQOw/kSglh1xfyxK56mx2JSHkaz6qBGGlWpMUkTFDQVY8z0E7gMU66BS2GicWqiKsMwUp2O4+5hkqNtGlc5JrlGyfitp+7/NaT1Tb76eEvrcFmzsg3P5ER+7/DTR/uf8E4+yOIOn32Ptz96oYVO+oCFOgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"API Credentials\"\n        src=\"/static/155924af3d07efd63686c2832452531d/e5715/api_creds.png\"\n        srcset=\"/static/155924af3d07efd63686c2832452531d/a6d36/api_creds.png 650w,\n/static/155924af3d07efd63686c2832452531d/e5715/api_creds.png 768w,\n/static/155924af3d07efd63686c2832452531d/67a79/api_creds.png 1408w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<h3 id=\"configuring-callback-urls\" style=\"position:relative;\"><a href=\"#configuring-callback-urls\" aria-label=\"configuring callback urls permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configuring Callback URLs</h3>\n<p>Here, a callback URL refers to a URL in your application that LoginRadius would redirect a user to after they have been authenticated.  These URLs must be added to your Application Configuration. If not set, users will be unable to login into the application and receive an error. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 49.69230769230769%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsTAAALEwEAmpwYAAABHklEQVQoz42R3XKCMBCFef/nskIr4h1iwER+IiYtDjAaxAjtSRidtjf6kc0cJpzdJetcr9emNZxOJ+yNpe/72zO01g6+E0JU1Vdd11V1LArOC9513fczjBlxECJNM5DnxdGCjK+a8zwnhMRYcSzlJ1CqG8dxam8Yhn/igYPAn8KPwqklSbaMsfV6jWw7xqIoQl+MUmiAApRSXBByOQgpRBAEvu8vPvzlIgiWq7fZfD5zVxbP9ZIkOVjKssQupVRKmcrGLIXnvbuuRzYxi8ok5NuQ03C/o9mGEEoZzGEYoiAxxFma4UaNWd9027Sc79EbhoSUZzzqPKHu6iEAer5cJrPWfY9hI4m+vAbKwmAvTGs7cAPENP/7uv0Vv4/M6w/SdjM1cIAxmgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"alt_text\"\n        src=\"/static/d2ce3fdc3f3a78d6bc963b6d58068857/e5715/whitelist_error.png\"\n        srcset=\"/static/d2ce3fdc3f3a78d6bc963b6d58068857/a6d36/whitelist_error.png 650w,\n/static/d2ce3fdc3f3a78d6bc963b6d58068857/e5715/whitelist_error.png 768w,\n/static/d2ce3fdc3f3a78d6bc963b6d58068857/00172/whitelist_error.png 1044w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<p>For security reasons, LoginRadius only processes API calls that are received from the whitelisted domains. To get the list of whitelisted domains, run <code>lr get domain</code> command from the CLI. Similarly, to add a domain, use the <code>lr add domain</code> command.</p>\n<blockquote>\n<p>For the purposes of this tutorial, make sure that you set <code>http://localhost</code> as a whitelisted domain. </p>\n</blockquote>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 52.15384615384615%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAABYlAAAWJQFJUiTwAAABD0lEQVQoz53Sz0rDMBzA8fxv1zVZ2o7uIIJnX2VP5WEedhTUhxO3detviVoGvoG/aIRVimgPHwJJ+01ISxhjaymlp4Q+EUKef8L1jbV2p7XeUko3Q8+g8K5Da0TuuBKeJ3Kr9GTPJG9wboeafwgb+dAKwYesKE719ZWrLy98WdU+nxrHGAdcaxH8wR51ofUZ5EJ2iclaNUlBCAkyUUAFA8oRpcBoGNn3BkP6wbTIT3pRglnMXT4zzlSFm5bWmXnptLbOziqvVHo8O/HvQbzDTmXpQTABSiZHwQUEUqivE+N4FoKBcD+I3uJkO1IveI9e49c6jNTERmiRR/Qe/6OXkVxshBZZohu0QrcjrWJj+QF3nKm34QUQlAAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Add Domain\"\n        src=\"/static/de3e6522371988cb07ec97614246ac15/e5715/domain.png\"\n        srcset=\"/static/de3e6522371988cb07ec97614246ac15/a6d36/domain.png 650w,\n/static/de3e6522371988cb07ec97614246ac15/e5715/domain.png 768w,\n/static/de3e6522371988cb07ec97614246ac15/891d5/domain.png 1520w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<h2 id=\"setup-react-js-application\" style=\"position:relative;\"><a href=\"#setup-react-js-application\" aria-label=\"setup react js application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setup React JS application</h2>\n<p>This tutorial uses a <a href=\"https://github.com/LoginRadius/engineering-blog-samples/tree/master/React/react_auth_demo\">demo app</a> based on the Create React App (CRA) boilerplate. For instructions on how to create a React App, refer to the following <a href=\"https://reactjs.org/docs/create-a-new-react-app.html\">docs</a>.</p>\n<p>The React Demo Application mentioned here will display the User Profile data if the login process is completed successfully.</p>\n<p>After setting up the boilerplate:</p>\n<ul>\n<li>\n<p>From the project root, install <code>react-router-dom</code>.</p>\n<p><code>npm install react-router-dom</code></p>\n</li>\n<li>Create <code>src/config.js</code> and add the application details in the code as shown below.</li>\n</ul>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk12\">config</span><span class=\"mtk1\"> = {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">APP_NAME:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&#39;&lt;&lt;App Name&gt;&gt;&#39;</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">API_KEY:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&#39;&lt;&lt;API Key&gt;&gt;&#39;</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  };</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk12\">config</span><span class=\"mtk1\">;</span></span></code></pre>\n<blockquote>\n<p>This tutorial uses LoginRadius Auth Page(IDX) for authentication, where Registration and Login functionality is already implemented. For example, you can navigate your Register buttons to <code>https://&#x3C;LoginRadius APP Name>.hub.loginradius.com/auth.aspx?action=register&#x26;return_url=&#x3C;Return URL></code>. </p>\n</blockquote>\n<h2 id=\"add-code-to-your-application\" style=\"position:relative;\"><a href=\"#add-code-to-your-application\" aria-label=\"add code to your application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Code to your Application</h2>\n<ul>\n<li>For this demo, we will start by populating the <code>App.js</code> file as shown below. Notice that the <code>/login</code> route has been added to the App component in which the <code>Login</code> and <code>Logout</code> components are rendered. They will be used to get the user profile data and handle user logout, respectively. The <code>/</code> route will load the <code>LandingPage</code> component. If you already have an existing React application, you can specify the route for these components as per your requirements. </li>\n</ul>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> { </span><span class=\"mtk12\">BrowserRouter</span><span class=\"mtk1\"> </span><span class=\"mtk15\">as</span><span class=\"mtk1\"> </span><span class=\"mtk12\">Router</span><span class=\"mtk1\">, </span><span class=\"mtk12\">Route</span><span class=\"mtk1\">, </span><span class=\"mtk12\">Switch</span><span class=\"mtk1\"> } </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react-router-dom&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;./App.css&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">LandingPage</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;./components/LandingPage&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">Login</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;./components/Login&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">Logout</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;./components/Logout&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">function</span><span class=\"mtk1\"> </span><span class=\"mtk11\">App</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Router</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk1\"> </span><span class=\"mtk12\">className</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;App&quot;</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Switch</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Route</span><span class=\"mtk1\"> </span><span class=\"mtk12\">exact</span><span class=\"mtk1\"> </span><span class=\"mtk12\">path</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;/&quot;</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">LandingPage</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">Route</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Route</span><span class=\"mtk1\"> </span><span class=\"mtk12\">path</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;/login&quot;</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk1\"> </span><span class=\"mtk12\">style</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk1\">{ </span><span class=\"mtk12\">display:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;flex&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">padding:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;1em&quot;</span><span class=\"mtk1\"> }</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">              </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Login</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">              </span><span class=\"mtk17\">&lt;</span><span class=\"mtk10\">Logout</span><span class=\"mtk1\"> </span><span class=\"mtk17\">/&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">            </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">Route</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">Switch</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk10\">Router</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk12\">App</span><span class=\"mtk1\">;</span></span></code></pre>\n<h3 id=\"add-landing-page\" style=\"position:relative;\"><a href=\"#add-landing-page\" aria-label=\"add landing page permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Landing Page</h3>\n<p>In your <code>components</code> folder under the <code>src</code> folder, create a <code>src/components/LandingPage.js</code> file and add the following code to navigate your Register/Login buttons to the following URL's as shown below.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">React</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">config</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;../config.js&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk11\">LandingPage</span><span class=\"mtk1\"> = () </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">h1</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\"> React Demo App </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">h1</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">a</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk12\">href</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk8\">`https://</span><span class=\"mtk4\">${</span><span class=\"mtk12\">config</span><span class=\"mtk1\">.</span><span class=\"mtk12\">APP_NAME</span><span class=\"mtk4\">}</span><span class=\"mtk8\">.hub.loginradius.com/auth.aspx?action=register&return_url=</span><span class=\"mtk4\">${</span><span class=\"mtk12\">window</span><span class=\"mtk1\">.</span><span class=\"mtk12\">location</span><span class=\"mtk1\">.</span><span class=\"mtk12\">origin</span><span class=\"mtk4\">}</span><span class=\"mtk8\">/login`</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Register</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">a</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">a</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk12\">href</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk8\">`https://</span><span class=\"mtk4\">${</span><span class=\"mtk12\">config</span><span class=\"mtk1\">.</span><span class=\"mtk12\">APP_NAME</span><span class=\"mtk4\">}</span><span class=\"mtk8\">.hub.loginradius.com/auth.aspx?action=login&return_url=</span><span class=\"mtk4\">${</span><span class=\"mtk12\">window</span><span class=\"mtk1\">.</span><span class=\"mtk12\">location</span><span class=\"mtk1\">.</span><span class=\"mtk12\">origin</span><span class=\"mtk4\">}</span><span class=\"mtk8\">/login`</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Login</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">a</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">};</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk12\">LandingPage</span><span class=\"mtk1\">;</span></span></code></pre>\n<p>By doing this, we are redirecting our application to the <strong>LoginRadius Auth Page</strong> and are passing the <code>return_url</code> as the current origin. After successful login, the <strong>Login</strong> component fetches the user profile data as shown in the following step. However, <code>return_url</code> can also be your website, backend server, etc., where you can handle the access token to perform different actions. </p>\n<h3 id=\"add-login-component\" style=\"position:relative;\"><a href=\"#add-login-component\" aria-label=\"add login component permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Login Component</h3>\n<p>In your <code>components</code> folder, create a <code>src/components/Login.js</code> file and add the following code to retrieve <strong>User Profile Data</strong>. </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">React</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> { </span><span class=\"mtk12\">withRouter</span><span class=\"mtk1\"> } </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react-router-dom&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">config</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;../config&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">class</span><span class=\"mtk1\"> </span><span class=\"mtk10\">Login</span><span class=\"mtk1\"> </span><span class=\"mtk4\">extends</span><span class=\"mtk1\"> </span><span class=\"mtk10\">React</span><span class=\"mtk1\">.</span><span class=\"mtk10\">Component</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk4\">constructor</span><span class=\"mtk1\">(</span><span class=\"mtk12\">props</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">super</span><span class=\"mtk1\">(</span><span class=\"mtk12\">props</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">state</span><span class=\"mtk1\"> = {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk12\">userProfileResponse:</span><span class=\"mtk1\"> </span><span class=\"mtk4\">null</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    };</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">componentDidMount</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk12\">token</span><span class=\"mtk1\"> = </span><span class=\"mtk4\">new</span><span class=\"mtk1\"> </span><span class=\"mtk10\">URLSearchParams</span><span class=\"mtk1\">(</span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">props</span><span class=\"mtk1\">.</span><span class=\"mtk12\">location</span><span class=\"mtk1\">.</span><span class=\"mtk12\">search</span><span class=\"mtk1\">).</span><span class=\"mtk11\">get</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;token&quot;</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">if</span><span class=\"mtk1\"> (</span><span class=\"mtk12\">token</span><span class=\"mtk1\">) {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk11\">fetch</span><span class=\"mtk1\">(</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk8\">&quot;`https://api.loginradius.com/identity/v2/auth/account?apikey=&quot;</span><span class=\"mtk1\"> +</span><span class=\"mtk8\">`</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          config.API_KEY,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          method: &quot;GET&quot;,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          headers: {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">            Authorization: &quot;Bearer &quot; + token,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          },</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">      )</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        .then((res) =&gt; res.json())</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        .then((res) =&gt; {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          this.setState({ userProfileResponse: res });</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        })</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        .catch((e) =&gt; {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">          console.log(e);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        });</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">    } else {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">      window.location.assign(</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk8\">        `</span><span class=\"mtk12\">https</span><span class=\"mtk1\">:</span><span class=\"mtk3\">//${config.APP_NAME}.hub.loginradius.com/auth.aspx?action=login&return_url=${window.location.origin}/login`</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk11\">render</span><span class=\"mtk1\">() {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk4\">const</span><span class=\"mtk1\"> { </span><span class=\"mtk12\">userProfileResponse</span><span class=\"mtk1\"> } = </span><span class=\"mtk4\">this</span><span class=\"mtk1\">.</span><span class=\"mtk12\">state</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">span</span><span class=\"mtk1\"> </span><span class=\"mtk12\">style</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk1\">{ </span><span class=\"mtk12\">whiteSpace:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;pre-wrap&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk12\">textAlign:</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;left&quot;</span><span class=\"mtk1\"> }</span><span class=\"mtk4\">}</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">          </span><span class=\"mtk4\">{</span><span class=\"mtk10\">JSON</span><span class=\"mtk1\">.</span><span class=\"mtk11\">stringify</span><span class=\"mtk1\">(</span><span class=\"mtk12\">userProfileResponse</span><span class=\"mtk1\">, </span><span class=\"mtk4\">null</span><span class=\"mtk1\">, </span><span class=\"mtk7\">4</span><span class=\"mtk1\">)</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">span</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  }</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk11\">withRouter</span><span class=\"mtk1\">(</span><span class=\"mtk12\">Login</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>The Login component will call the LoginRadius API to fetch the user data by making use of the <code>token</code> obtained upon logging in via the <strong>LoginRadius Auth Page</strong>. </p>\n<h3 id=\"add-logout-component\" style=\"position:relative;\"><a href=\"#add-logout-component\" aria-label=\"add logout component permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Add Logout component</h3>\n<p>In your <code>components</code> folder, create a <code>src/components/Logout.js</code> file and add the code as shown below.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"js\" data-index=\"10\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">React</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;react&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">import</span><span class=\"mtk1\"> </span><span class=\"mtk12\">config</span><span class=\"mtk1\"> </span><span class=\"mtk15\">from</span><span class=\"mtk1\"> </span><span class=\"mtk8\">&quot;../config.js&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">const</span><span class=\"mtk1\"> </span><span class=\"mtk11\">Logout</span><span class=\"mtk1\"> = () </span><span class=\"mtk4\">=&gt;</span><span class=\"mtk1\"> {</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk12\">localStorage</span><span class=\"mtk1\">.</span><span class=\"mtk11\">removeItem</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;token&quot;</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  </span><span class=\"mtk15\">return</span><span class=\"mtk1\"> (</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">div</span><span class=\"mtk1\"> </span><span class=\"mtk12\">class</span><span class=\"mtk1\">=</span><span class=\"mtk8\">&quot;container&quot;</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">a</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk12\">href</span><span class=\"mtk1\">=</span><span class=\"mtk4\">{</span><span class=\"mtk8\">`https://</span><span class=\"mtk4\">${</span><span class=\"mtk12\">config</span><span class=\"mtk1\">.</span><span class=\"mtk12\">APP_NAME</span><span class=\"mtk4\">}</span><span class=\"mtk8\">.hub.loginradius.com/auth.aspx?action=logout&return_url=http://localhost:3000/`</span><span class=\"mtk4\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">        </span><span class=\"mtk17\">&lt;</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span><span class=\"mtk1\">Logout</span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">button</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">      </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">a</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk17\">&lt;/</span><span class=\"mtk4\">div</span><span class=\"mtk17\">&gt;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">  );</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">};</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk15\">export</span><span class=\"mtk1\"> </span><span class=\"mtk15\">default</span><span class=\"mtk1\"> </span><span class=\"mtk12\">Logout</span><span class=\"mtk1\">;</span></span></code></pre>\n<p>This component contains logout functionality. Here, <code>action=logout</code> is passed to the <strong>LoginRadius Auth Page</strong>, which will log the user out and return them to the Landing Page specified in the <code>return_url</code>. </p>\n<blockquote>\n<p>Full code of the demo can be found on <a href=\"https://github.com/LoginRadius/engineering-blog-samples/tree/master/React/react_auth_demo\">github</a>.</p>\n</blockquote>\n<h3 id=\"testing-the-application\" style=\"position:relative;\"><a href=\"#testing-the-application\" aria-label=\"testing the application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Testing the application</h3>\n<p>Run the React Application from the command line using <code>npm start</code>. You will be able to see the output on <code>localhost:3000</code>. You can also directly open the IDX page on <code>https://&#x3C;LoginRadius APP Name>.hub.loginradius.com/auth.aspx?action=register&#x26;return_url=http://localhost:3000/login</code>.</p>\n<p>Congratulations! You have set up a React Application configured with LoginRadius using LoginRadius CLI. Continue reading to check out some cool and advanced features of the LoginRadius CLI that will help you manipulate and configure the LoginRadius Auth Page for your application through the CLI. </p>\n<h2 id=\"advanced-loginradius-cli-features\" style=\"position:relative;\"><a href=\"#advanced-loginradius-cli-features\" aria-label=\"advanced loginradius cli features permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Advanced LoginRadius CLI features</h2>\n<p>This section explains the use of the LoginRadius CLI in enabling users to quickly and efficiently make changes to the <strong>LoginRadius Auth Page</strong> configured for their application. </p>\n<h3 id=\"adding-social-login-methods\" style=\"position:relative;\"><a href=\"#adding-social-login-methods\" aria-label=\"adding social login methods permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Adding Social Login Methods</h3>\n<p>We can add social login methods like Google, Facebook, etc., to the LoginRadius Auth Page using the CLI. Use the <code>lr add social</code> command to add a Login method and the <code>lr get social</code> command to view the current active social login methods. Check the image below for a visual representation. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 70.3076923076923%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAABYlAAAWJQFJUiTwAAACJ0lEQVQ4y52TyY7TMBjHvSRx7NhZmqQtXWY6HcQiNAfEQ3DiZbhxgEFC3BGaHgAxB15jEK+CuthOB9QyPAGf23TUViO2w0+243z//L8lyPf9x5zz15TS5wihF8Dp9ooxPpVSvnS4fX23j4t9BTxB8NIbSugPOEwBDZhtMMJGCGF5GFq337+vcbEL4L0TfBtE4TxMozHP46kvwgnCaIwJmWCCx5iSCXKrByvGYwi6ia+ABT4A6Czrlcv8Ts9mg3aVDlpV3C1sctCs4l5R8SQyTAkTlYmlgecymNWZbJjVDi+B85WgKtNFebdvVZ7YQHETggjPlAlTaZgUpg76HbuCURYvkn5pkk5hwzgCIXAVi5Wgg1Ci91zd5PDbtSBh3nfKA6gfMx5nmjJfE0gPnmvsUw011X9wOLl2SAkZFd3Wshx2TQNqKNuZZeBSFonN2oVNm7kN1dqtz5kJM7kqCXO4bACRx5p4dO0wYMHo3qOTq/sPT2xx2KmKB4dz0WlYVaRmcHtYHRwNKs/3XICGjmtS77eBZk0hi7UgpDaS/WKZDFtGZLGRvjCKBiZCnmYI679oyG5TqO+N1K18kfabOu7mNoqEySJlGjK2pUysENy4OpIaNzqEkO3x2RUEh2eN485C5ek0aXagNlL7MpwFsdAO3lAa6qeZOyuuYZw0lGAjssEN9xz46Lr8Dv6In7BWCOHL+kv/CsSiK+CTE3wKfAEugM//yUWt8ewXEr/6RdvxeekAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Facebook Login Added\"\n        src=\"/static/cc40ce7cc44ddebce1f77e1e56f6c20a/e5715/lr_social.png\"\n        srcset=\"/static/cc40ce7cc44ddebce1f77e1e56f6c20a/a6d36/lr_social.png 650w,\n/static/cc40ce7cc44ddebce1f77e1e56f6c20a/e5715/lr_social.png 768w,\n/static/cc40ce7cc44ddebce1f77e1e56f6c20a/c8ad9/lr_social.png 1564w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<p>After adding the new login method (in this example, it is Facebook), navigate to the LoginRadius Auth Page by using the <code>lr demo</code> command.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 60.92307692307693%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACTklEQVQoz12Ry2sTQRzHt22aZrPNzCTZV7b7SDbJbrI23TzagvZWEbWCRbEgFQQPnvoXeBQvgtA8dpPmoBTBk6IgKOpRPPbgH2ERxYOCGFEzs86uBh/Dhzn84MN3vr9hFqvOYs2tN1rN1opbb1YqjlW2i07DWDltrJyi5P/i18RaO9s8ub14fIvRFxTLstScnM1k4rFYqZBfdR1ncwd2v6HOiALbIzABRpN0d5TpfU13Roxbqxm6bugaz2cLhrG8vGoZirh2EQ4C6I+BN+YHWBliaQ/nhjjTx8DHkOKFN1NbciEAsZmZVJItF01N01Fimj+6RWXkj7neuLqPNx7iEw/w+n3s7EfmBGbJrdtFk43PUplHUJYVTUD6+pUoGQMPCwOSG5LsgCS6ZGqXcD2CfAIjmEaTnlbRNA1NlbNIlnOGmEatc1EyZrtk+R6++mK8/ZRQLj8jlX2SnPhMuWAUDF0SeB6mbNOQRYGbYmBzk8q04cwuvvScHHwIXh4Grw6Dg3fBxiMSa5N0P5JNfUGVBMjGubm4JotO2SxJKXUt7Ey3khoEys3DIzde1+6GmaU7RNwjwJs8u+66FcsS0wAk4rqqlUq2Allh9TzaC2XYD+Ctj/PX33BeQB1aGEwKR3KjWSkWRJRCyTmJ5y3Lnp9muMYmlZGHOT+ott9ee/J+5/En3v+B+n+2FcqOTf9VoqYAkhkwb5dLOpxla2d+b9sPhM6X6vBz9fZ3FH4Pgf8ku428pvKpRC4D8oqkKnJZYJVjF0Akh36fsF7A9oL/TMpPz0IKW6ETzF8AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Facebook Login Added on IDX\"\n        src=\"/static/95db8a5404c417af55e16f947fa3e4a7/e5715/add_login.png\"\n        srcset=\"/static/95db8a5404c417af55e16f947fa3e4a7/a6d36/add_login.png 650w,\n/static/95db8a5404c417af55e16f947fa3e4a7/e5715/add_login.png 768w,\n/static/95db8a5404c417af55e16f947fa3e4a7/60708/add_login.png 2872w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<h3 id=\"updating-the-theme\" style=\"position:relative;\"><a href=\"#updating-the-theme\" aria-label=\"updating the theme permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Updating the theme</h3>\n<p>We can update the <strong>theme</strong> of the LoginRadius Auth Page using the <code>lr set theme</code> command. You can use the <code>lr get theme</code> command to get a list of all available themes and the currently active theme. See the image below for visual representation. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 81.07692307692308%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAABYlAAAWJQFJUiTwAAABg0lEQVQ4y52UXU7CQBCAt0u73V/KUkQS33zwLHoogg96AGIk8UZi4hkM0O5ioMgRnKnFAAEtPHyd7nbn2+lOWhKG4R0X4hFinxAyKAmqCARBMJBS3iN4/7tmF8x9AG4JpXTYoHQNgxmQb+EQeO6MMXMQehC6zfwemPsFDAHyxIz8FGlzorqtmTBqqiFGMp7Cs0lNPoA5ulA44okqVNfmutf2yhpnIIIQd872qj4ErsHNl+gqhXEiC9lJMnVpve4knkm+LctqsCuUbbuy1z0XcpbHTelCFuU1KsuPCOlI2XSV3ly5MI7qVvR3hbypCmFNBk3xXAkn06aHJnmmxc+rB0G+IYDKKIFYjo+coUz0Cs9QtI1TF4nHWAINwuYwIxw0zjE4DhMLlzLltFKO8uiwkMXxUhmT0bCR7xA18rO6DFUUvKUzbrXDpmBEBHDWGQKLavLQ4lO7XF6WW8JjSbUrfP6nwrrCReUiL8C6+sjnZ+IqB7rKX8878AqMgbcTGVe56Oh/A9VBFD6Xc+bWAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Theme changed to Tokyo\"\n        src=\"/static/84b4b1478e671e85af02ea1800ddc4b6/e5715/lr_theme.png\"\n        srcset=\"/static/84b4b1478e671e85af02ea1800ddc4b6/a6d36/lr_theme.png 650w,\n/static/84b4b1478e671e85af02ea1800ddc4b6/e5715/lr_theme.png 768w,\n/static/84b4b1478e671e85af02ea1800ddc4b6/891d5/lr_theme.png 1520w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<p>After changing the theme, navigate to the LoginRadius Auth Page using <code>lr demo</code> command to view the changes. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 56.30769230769231%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA6klEQVQoz2OQ0jL9L6lp8l9a2wxMi6kZ/hcnEYupGfyX1TH/LwPEDMJqRv/BWBVCi6gbY2BRKBbBg4VVDcFmMIgiaQBjoKFgDFUkCXS5sZPPf1VTx//iGib/RcByRgh1SOpBGNNAJCykYvhfzczpv4V74H9zt4D/yib2YEvw6cFqoAjchRBazdzpv6qZI1gcJieC5CqCBiIbHJac87+kvu1/UW0LmI3LIKINzCmv/z9t3mIgXvI/r7IR7mqyvCyiavCfT93yv6RHzn9RDdP/vAo68Fgn2cuw8BIDxiwypsjL6C4hZBhRBpKKAdIzRNK8IlIjAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"New Theme Tokyo\"\n        src=\"/static/614434594406fb262981bbdf7a033839/e5715/set_theme.png\"\n        srcset=\"/static/614434594406fb262981bbdf7a033839/a6d36/set_theme.png 650w,\n/static/614434594406fb262981bbdf7a033839/e5715/set_theme.png 768w,\n/static/614434594406fb262981bbdf7a033839/29114/set_theme.png 1920w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<h3 id=\"adding-to-the-registration-schema\" style=\"position:relative;\"><a href=\"#adding-to-the-registration-schema\" aria-label=\"adding to the registration schema permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Adding to the Registration schema</h3>\n<blockquote>\n<p>This functionality is only available for paid <strong>Developer Plans and above</strong> (not available for LoginRadius Free plan). </p>\n</blockquote>\n<p>We can update the Registration Page schema using the <code>lr add schema</code> command. Use the <code>lr get schema</code> command with <code>--active</code> or <code>--all</code> flags to get the current Registration fields or view all available fields with their schemas. You can also configure addtional features by choosing the <code>setup advance configuration</code> option.<br>\nSee the image below for a visual representation of the command flow. </p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 101.38461538461539%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAABYlAAAWJQFJUiTwAAAB+0lEQVQ4y52SW3LaMBSGdbF8l+9ACEynmUzabWRHfUoXkYc+ZKbu4ppCE5DkTCBkCf0FfqCUmotnPoM11uej/xzCGb93hWgooT8JIb92YYxNsiz7LaWcUkon+94Bdq8B94A8ME80PHCnIvafHVc8cc6fsH4Kk1b4QCghddEvV+W4r4uri6a8vmyKq2GTjntNnEqTFKkJ0kjHg9z4MtQeCMvEuHGgIZgDBZ7BAtSEcVZng2KV5uk8LnKTfug3YS8xjhBKML6GbjbNO9gSOrzOrofvEKk465kw7BlGxT6BOkpobzJP36JUzimnijNPOY6vtiSH+FcoPHchAm8mIl8zwQ4dr7tCjEsd97I3eVmqZFSZCOF7ySZ4H80I8lj72QbbEDcKtId1S4B3ROjpvzNkrE4uipUcVWthhu5CbsJc6rBKjSUeFibCsyMcRTlTyH0Nb593KsTYDKpV+Xmsq5vxixXmGBtpJajWxhBAFhT4QBJpRKM7j4yv1Jg722VtR6a8Gb3kHzGPnyAfViYZFCZMY93RpJ0MGa2RwxLMROhrW5HFDq4rkRfytL//Ee4fG/DaLnZ1Uu387xQutoRd83Z0hYudCtUJQ32U8PzBxvX9yAwPCV9bF/kBlmDWHkOfiGr3LlsX+dYuPoLpmTy2Dusit+ALuANfz+Suddz+AQRLYaR/52B7AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Get and Add to Reg. Schema\"\n        src=\"/static/1c94f8eb16492c0df93ff90860e88db3/e5715/lr_schema.png\"\n        srcset=\"/static/1c94f8eb16492c0df93ff90860e88db3/a6d36/lr_schema.png 650w,\n/static/1c94f8eb16492c0df93ff90860e88db3/e5715/lr_schema.png 768w,\n/static/1c94f8eb16492c0df93ff90860e88db3/891d5/lr_schema.png 1520w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<p>In the below image 2 fields have been added to the registration schema, <code>Confirm Password</code> and <code>Gender</code>. To view the changes, navigate to the LoginRadius Auth Page using <code>lr demo</code>command.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 768px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 56.30769230769231%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABPElEQVQoz2OQ0jL9L6lp8l9a2wyIQWxjMBZXN/ovrmb4X0zV4L+Qku5/ERX9/2JAvjgaBoupG/6X07X4Lw00i0FYzeg/GKtCaBEoX0TdGEyLa5n9V7dw/i9vYPNfTMMEKG8MlkPBQDEhVUOwegZRoAAuLAxUJKNn+d/AwQtsqJSOOdhCsDyIhmF1I7gevAYKqRj+VzVz/G/pEfTfyjP4v7KJPdgSfHrwGghyjZSu5X8tG/f/2rYe/yV1LPAaRtBAULjWNXX8X71qLRCv+9/Q0km+C0GBDYrh3Rs3/X//7PH/jy+f/d+3ZStYTIRsA4Fe9nD3/R+b1/Q/OrsWyPb5LwaVI8lAWEyCNHLLaPzn13P7z6ft+J9LRh0ew/DYJtqFUE3imqZAb+oBsT6YLQJNo2RFCsK1JmCMy1XIGAAOmUzLlrV7JwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"alt_text\"\n        title=\"Added Fields\"\n        src=\"/static/974028afb0b77e477add1109ab24a1a3/e5715/add_schema.png\"\n        srcset=\"/static/974028afb0b77e477add1109ab24a1a3/a6d36/add_schema.png 650w,\n/static/974028afb0b77e477add1109ab24a1a3/e5715/add_schema.png 768w,\n/static/974028afb0b77e477add1109ab24a1a3/29114/add_schema.png 1920w\"\n        sizes=\"(max-width: 768px) 100vw, 768px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n    </span> </p>\n<blockquote>\n<p>Instead of using the <code>lr demo</code> command, you can also view the <strong>LoginRadius Auth Page</strong> by visiting locahost:3000 and following the same workflow as explained earlier.</p>\n</blockquote>\n<p>The entire description for these commands can be found in the <a href=\"https://www.loginradius.com/open-source/cli/manual\">LoginRadius CLI Manual</a>.</p>\n<h2 id=\"contributing-to-loginradius-cli\" style=\"position:relative;\"><a href=\"#contributing-to-loginradius-cli\" aria-label=\"contributing to loginradius cli permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Contributing to LoginRadius CLI</h2>\n<p>The <a href=\"https://github.com/LoginRadius/lr-cli/\">LoginRadius CLI</a> is open-sourced under <a href=\"https://github.com/LoginRadius\">LoginRadius Organization</a>. You are welcome to contribute to it, suggest improvements, or report bugs by following the contributing guidelines. You can also checkout our <a href=\"https://www.loginradius.com/open-source/\">open source page</a> if you wish to contribute to other opensource projects by LoginRadius.</p>\n<h2 id=\"your-take\" style=\"position:relative;\"><a href=\"#your-take\" aria-label=\"your take permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Your Take</h2>\n<p>Using the LoginRadius CLI, you can easily setup authentication for your React applications. You can also perform certain LoginRadius functionalities and processes efficiently through the CLI, which saves a bunch of time. LoginRadius will handle all the authentication-related mechanisms so that you can solely concentrate on your application development.</p>\n<p>I hope you enjoyed this tutorial and found it to be useful. You can provide feedback or suggestions in the comment section below. </p>\n<p>Cheers!!!</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n  .dark-default-dark .mtk15 { color: #C586C0; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk17 { color: #808080; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk3 { color: #6A9955; }\n  .dark-default-dark .mtk7 { color: #B5CEA8; }\n</style>","frontmatter":{"date":"May 12, 2021","updated_date":null,"description":"In this tutorial, we will learn about implementing authentication for React applications using LoginRadius in under 5 mins. We will be using the LoginRadius CLI, through which we can perform basic actions of the LoginRadius Dashboard on the command line in a fast and proficient manner.","title":"Implement Authentication in React Applications using LoginRadius CLI ","tags":["Authentication","React","CLI","LoginRadius CLI"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/ebd0bed97181739f12158e74609a96c6/14b42/cover.jpg","srcSet":"/static/ebd0bed97181739f12158e74609a96c6/f836f/cover.jpg 200w,\n/static/ebd0bed97181739f12158e74609a96c6/2244e/cover.jpg 400w,\n/static/ebd0bed97181739f12158e74609a96c6/14b42/cover.jpg 800w,\n/static/ebd0bed97181739f12158e74609a96c6/47498/cover.jpg 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Akash Patil","github":"Akash-Patil","avatar":null}}}},{"node":{"excerpt":"Recoil js is another state management library for React. Though we already have Redux. Mobx, Context, but here we got a new light entry in…","fields":{"slug":"/engineering/recoiling-the-react/"},"html":"<p><a href=\"https://recoiljs.org/\" title=\"Recoil js\">Recoil js</a> is another state management library for React.</p>\n<p>Though we already have Redux. Mobx, Context, but here we got a new light entry in the community.</p>\n<p>Why I am saying <code>light</code> you will figure it out at the end of this blog.</p>\n<h2 id=\"why-recoil\" style=\"position:relative;\"><a href=\"#why-recoil\" aria-label=\"why recoil permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Recoil</h2>\n<ul>\n<li>Firstly, it solves the global state management problems.</li>\n<li>Easy to learn; there are no new major principles n logic to learn.</li>\n<li>Quite Simple, it is similar like react.</li>\n<li>Though I like redux, but it will not take that much time to learn.</li>\n</ul>\n<h2 id=\"recoil--concepts\" style=\"position:relative;\"><a href=\"#recoil--concepts\" aria-label=\"recoil  concepts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Recoil  concepts</h2>\n<p>There are two major concepts:</p>\n<ol>\n<li><strong>Atoms</strong> </li>\n<li><strong>Selectors</strong></li>\n</ol>\n<p>Something new? Don't worry will understand this quickly.</p>\n<h3 id=\"atoms\" style=\"position:relative;\"><a href=\"#atoms\" aria-label=\"atoms permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Atoms</h3>\n<p> This is similar to how we use the <code>useState</code> hook in react. If you are new to react hooks, checkout <a href=\"https://www.loginradius.com/blog/engineering/react-hooks-guide/\" title=\"react hooks guide\">react hooks guide</a>.</p>\n<p> e.g.:</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"> const [age, setAge] = useState(0);</span></code></pre>\n<p><strong>age</strong> : this will be used for state variable declaration.\n<strong>setAge</strong> :this will be used for state variable updations.</p>\n<h4 id=\"1-lets-start-with-binding-root-app-with-recoil\" style=\"position:relative;\"><a href=\"#1-lets-start-with-binding-root-app-with-recoil\" aria-label=\"1 lets start with binding root app with recoil permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Let's start with binding root app with Recoil</h4>\n<p>Now you need to make a few alterations in your app's root level, like the below snippet.</p>\n<p><code>RecoilRoot</code> will behave like a global context provider that will share the global state to your app tree.</p>\n<p>Now update your older code snippet.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">ReactDOM.render( &lt;AppPage /&gt;, document.getElementById(&quot;root&quot;))</span></code></pre>\n<p>to </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import { RecoilRoot } from &quot;recoil&quot;;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">ReactDOM.render( </span>\n<span class=\"grvsc-line\"> &lt;RecoilRoot&gt;</span>\n<span class=\"grvsc-line\">    &lt;AppPage /&gt;</span>\n<span class=\"grvsc-line\"> &lt;/RecoilRoot&gt;, document.getElementById(&quot;root&quot;))</span></code></pre>\n<h4 id=\"2-set-the-atom\" style=\"position:relative;\"><a href=\"#2-set-the-atom\" aria-label=\"2 set the atom permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Set the Atom</h4>\n<p>Recoil calls this part as <strong>atom</strong>, where we set the global key, value.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import { atom } from &quot;recoil&quot;;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const age = atom({</span>\n<span class=\"grvsc-line\">  key: &quot;age&quot;, </span>\n<span class=\"grvsc-line\">  default: 0  // default global value for age key</span>\n<span class=\"grvsc-line\">});</span></code></pre>\n<p>Now this atom will be accessible throughout the app.</p>\n<h4 id=\"3-use-the-atom\" style=\"position:relative;\"><a href=\"#3-use-the-atom\" aria-label=\"3 use the atom permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. use the atom</h4>\n<p>Now update your older code snippet.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"4\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"> const [age, setAge] = useState(0);</span></code></pre>\n<p>to </p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"5\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import { useRecoilState } from &#39;recoil&#39;</span>\n<span class=\"grvsc-line\">const [ageState, setAge] = useRecoilState(age);</span></code></pre>\n<p>For a Larger view, here is <strong>Full Code</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"6\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import { atom,useRecoilState } from &#39;recoil&#39;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const age = atom({</span>\n<span class=\"grvsc-line\">  key: &quot;age&quot;, </span>\n<span class=\"grvsc-line\">  default: 0  // default global value for age key</span>\n<span class=\"grvsc-line\">});</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">export const AgeCalculator = () =&gt; {</span>\n<span class=\"grvsc-line\">const [ageState, setAge] = useRecoilState(age);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>Quite easy. Isn't it?\nNow let's move to another part <strong>selectors</strong>.</p>\n<h3 id=\"selectors\" style=\"position:relative;\"><a href=\"#selectors\" aria-label=\"selectors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Selectors</h3>\n<p>This is similar to how Redux manages states.</p>\n<p>if a value can be derived/computed from the state, then we can skip re initialize of an another separate state key, for that use selectors.</p>\n<h4 id=\"1-set-the-selectors\" style=\"position:relative;\"><a href=\"#1-set-the-selectors\" aria-label=\"1 set the selectors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. set the selectors</h4>\n<p>In the below example, we are getting <code>isChild</code> value from <code>age</code> key, then we can directly use <strong>selector</strong> instead of adding a new key or <strong>atom</strong>.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"7\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import {selector} from &#39;recoil&#39;</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const isChild = selector({</span>\n<span class=\"grvsc-line\">  key: &quot;childage&quot;,</span>\n<span class=\"grvsc-line\">  get: ({ get }) =&gt; {</span>\n<span class=\"grvsc-line\">    const state = get(age);</span>\n<span class=\"grvsc-line\">    return state &lt; 10 ;</span>\n<span class=\"grvsc-line\">  }</span>\n<span class=\"grvsc-line\">});</span></code></pre>\n<h4 id=\"2-use-the-selectors\" style=\"position:relative;\"><a href=\"#2-use-the-selectors\" aria-label=\"2 use the selectors permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. use the selectors</h4>\n<p>Now will use the above-mentioned selector.</p>\n<p>below code snippet use <code>age</code> value to <code>isChild</code>.</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"8\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">  const [ageState, setAge] = useRecoilState(age);</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">  const value = useRecoilValue(isChild);</span></code></pre>\n<p>For a larger view, here is <strong>Full Code</strong></p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"\" data-index=\"9\"><code class=\"grvsc-code\"><span class=\"grvsc-line\">import {selector, useRecoilState} from &#39;recoil&#39; </span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">const isChild = selector({</span>\n<span class=\"grvsc-line\">  key: &quot;childage&quot;,</span>\n<span class=\"grvsc-line\">  get: ({ get }) =&gt; {</span>\n<span class=\"grvsc-line\">    const state = get(age);</span>\n<span class=\"grvsc-line\">    return state &lt; 10 ;</span>\n<span class=\"grvsc-line\">  }</span>\n<span class=\"grvsc-line\">});</span>\n<span class=\"grvsc-line\"></span>\n<span class=\"grvsc-line\">export const AgeCalculator = () =&gt; {</span>\n<span class=\"grvsc-line\">    const [ageState, setAge] = useRecoilState(age);</span>\n<span class=\"grvsc-line\">   const value = useRecoilValue(isChild);</span>\n<span class=\"grvsc-line\">}</span></code></pre>\n<p>That's all, Milord.</p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>I hope you got why I am saying this as <strong><code>light</code></strong>.</p>\n<p>Recoil is looking relatively easy, promising, and early-stage, but again this is the next generation, and it will take time to get the own space in the <a href=\"https://community.loginradius.com/\">community</a>.  </p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n</style>","frontmatter":{"date":"April 30, 2021","updated_date":null,"description":"Recoil is an experimental state management library and It provides several capabilities that are difficult to achieve with React alone.In this article we learn about the recoil.js, and how it is managing state in react.","title":"What is recoil.js and how it is managing in react?","tags":["JavaScript","React","Recoil"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/f37a15f3f8cda8461c5455bdd2895e0c/ee604/react.png","srcSet":"/static/f37a15f3f8cda8461c5455bdd2895e0c/69585/react.png 200w,\n/static/f37a15f3f8cda8461c5455bdd2895e0c/497c6/react.png 400w,\n/static/f37a15f3f8cda8461c5455bdd2895e0c/ee604/react.png 800w,\n/static/f37a15f3f8cda8461c5455bdd2895e0c/f3583/react.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Abhimanyu Singh Rathore","github":"abhir9","avatar":null}}}},{"node":{"excerpt":"Introduction As we all know that Enums are very commonly used in the C# program. While using the Enums, we should also be aware of how the…","fields":{"slug":"/engineering/how-enum-tryparse-works-in-csharp/"},"html":"<h2 id=\"introduction\" style=\"position:relative;\"><a href=\"#introduction\" aria-label=\"introduction permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>As we all know that Enums are very commonly used in the C# program. While using the Enums, we should also be aware of how the values are parsed into the Enums. In my earlier article, I have talked about the <a href=\"https://www.loginradius.com/blog/engineering/enum-csharp/\">How to Use Enum in C#</a>.In this article, I will specifically talk about the mistake we can make while using the <strong>Enum.TryParse()</strong> method.</p>\n<h2 id=\"lets-get-started\" style=\"position:relative;\"><a href=\"#lets-get-started\" aria-label=\"lets get started permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Let's get started</h2>\n<p>As we know <code>Enum.Tryparse()</code> method will give us the parsed Enum. Like in the below example</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"c#\" data-index=\"0\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">public</span><span class=\"mtk1\"> </span><span class=\"mtk4\">enum</span><span class=\"mtk1\"> </span><span class=\"mtk10\">IdentityProtocols</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">{</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">SAML</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">OAuth</span><span class=\"mtk1\">,</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">    </span><span class=\"mtk12\">OpenID</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk1\">}</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">isEnumParsed</span><span class=\"mtk1\">=</span><span class=\"mtk12\">Enum</span><span class=\"mtk1\">.</span><span class=\"mtk11\">TryParse</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;0&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk4\">true</span><span class=\"mtk1\">, </span><span class=\"mtk4\">out</span><span class=\"mtk1\"> </span><span class=\"mtk10\">IdentityProtocols</span><span class=\"mtk1\"> </span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk12\">Console</span><span class=\"mtk1\">.</span><span class=\"mtk11\">WriteLine</span><span class=\"mtk1\">(</span><span class=\"mtk12\">isEnumParsed</span><span class=\"mtk1\">?</span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">.</span><span class=\"mtk11\">ToString</span><span class=\"mtk1\">():</span><span class=\"mtk8\">&quot;Not Parsed&quot;</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>The above code will print the <code>SAML</code> because the enum is started by default with the value 0.</p>\n<p>What happens if we run the below code with the same Enum declaration?</p>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"c#\" data-index=\"1\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">isEnumParsed</span><span class=\"mtk1\">=</span><span class=\"mtk12\">Enum</span><span class=\"mtk1\">.</span><span class=\"mtk11\">TryParse</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;-1&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk4\">true</span><span class=\"mtk1\">, </span><span class=\"mtk4\">out</span><span class=\"mtk1\"> </span><span class=\"mtk10\">IdentityProtocols</span><span class=\"mtk1\"> </span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk12\">Console</span><span class=\"mtk1\">.</span><span class=\"mtk11\">WriteLine</span><span class=\"mtk1\">(</span><span class=\"mtk12\">isEnumParsed</span><span class=\"mtk1\">?</span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">.</span><span class=\"mtk11\">ToString</span><span class=\"mtk1\">():</span><span class=\"mtk8\">&quot;Not Parsed&quot;</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>As per our understanding isEnumParsed variable should be <code>false</code>, and the above code should print <strong>Not Parsed</strong> as the value which we are passing in the method is not in the Enum declaration, right?</p>\n<p>But here is a catch, isEnumParsed variable have the <code>true</code> value, and the code will print <code>-1</code>.</p>\n<h2 id=\"why-enumtryparse-parse-int-values\" style=\"position:relative;\"><a href=\"#why-enumtryparse-parse-int-values\" aria-label=\"why enumtryparse parse int values permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why Enum.tryParse() parse int values?</h2>\n<p>The default type of Enum in C# is <code>int</code>. That's why any valid integer values are parsed by the Enum.TryParse() method irrespective of those integer values are defined in the Enum or not. </p>\n<p>We can define the Enum with types like byte, sbyte, etc. Then the Enum.TryParse() will parse those values which will fall in that defined Enum type.</p>\n<h2 id=\"how-to-overcome-this-behavior-of-enumtryparse\" style=\"position:relative;\"><a href=\"#how-to-overcome-this-behavior-of-enumtryparse\" aria-label=\"how to overcome this behavior of enumtryparse permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to overcome this behavior of Enum.TryParse()</h2>\n<p>To overcome this behavior of Enum.TryParse() we can follow the below approaches.</p>\n<h3 id=\"1-using-enumisdefined-method-with-enumtryparse-method\" style=\"position:relative;\"><a href=\"#1-using-enumisdefined-method-with-enumtryparse-method\" aria-label=\"1 using enumisdefined method with enumtryparse method permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Using Enum.IsDefined() method with Enum.TryParse() method</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"c#\" data-index=\"2\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">isValidEnum</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">Enum</span><span class=\"mtk1\">.</span><span class=\"mtk11\">TryParse</span><span class=\"mtk1\">(</span><span class=\"mtk8\">&quot;-1&quot;</span><span class=\"mtk1\">, </span><span class=\"mtk4\">true</span><span class=\"mtk1\">, </span><span class=\"mtk4\">out</span><span class=\"mtk1\"> </span><span class=\"mtk10\">IdentityProtocols</span><span class=\"mtk1\"> </span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">) && </span><span class=\"mtk12\">Enum</span><span class=\"mtk1\">.</span><span class=\"mtk11\">IsDefined</span><span class=\"mtk1\">(</span><span class=\"mtk4\">typeof</span><span class=\"mtk1\">(</span><span class=\"mtk10\">IdentityProtocols</span><span class=\"mtk1\">), </span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">);</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk12\">Console</span><span class=\"mtk1\">.</span><span class=\"mtk11\">WriteLine</span><span class=\"mtk1\">(</span><span class=\"mtk12\">isValidEnum</span><span class=\"mtk1\"> ? </span><span class=\"mtk12\">parsedEnumValue</span><span class=\"mtk1\">.</span><span class=\"mtk11\">ToString</span><span class=\"mtk1\">(): </span><span class=\"mtk8\">&quot;Not Parsed&quot;</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>In the above code <strong>Enum.IsDefined()</strong> will check that the value which we are getting from the Enum.TryParse() method is defined in the Enum declaration or not.</p>\n<p>That will give us the proper result, and the above code will print <code>Not Parsed</code></p>\n<h3 id=\"2using-enumgetnames-method\" style=\"position:relative;\"><a href=\"#2using-enumgetnames-method\" aria-label=\"2using enumgetnames method permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2.Using Enum.GetNames() method</h3>\n<pre class=\"grvsc-container dark-default-dark\" data-language=\"c#\" data-index=\"3\"><code class=\"grvsc-code\"><span class=\"grvsc-line\"><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">value</span><span class=\"mtk1\"> = </span><span class=\"mtk8\">&quot;-1&quot;</span><span class=\"mtk1\">;</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk4\">var</span><span class=\"mtk1\"> </span><span class=\"mtk12\">identityProtocolsList</span><span class=\"mtk1\"> = </span><span class=\"mtk12\">Enum</span><span class=\"mtk1\">.</span><span class=\"mtk11\">GetNames</span><span class=\"mtk1\">(</span><span class=\"mtk4\">typeof</span><span class=\"mtk1\">(</span><span class=\"mtk10\">IdentityProtocols</span><span class=\"mtk1\">)).</span><span class=\"mtk11\">ToList</span><span class=\"mtk1\">();</span></span>\n<span class=\"grvsc-line\"><span class=\"mtk12\">Console</span><span class=\"mtk1\">.</span><span class=\"mtk11\">WriteLine</span><span class=\"mtk1\">(</span><span class=\"mtk12\">identityProtocolsList</span><span class=\"mtk1\">.</span><span class=\"mtk11\">Contains</span><span class=\"mtk1\">(</span><span class=\"mtk12\">value</span><span class=\"mtk1\">) ? </span><span class=\"mtk12\">value</span><span class=\"mtk1\"> : </span><span class=\"mtk8\">&quot;Not Parsed&quot;</span><span class=\"mtk1\">);</span></span></code></pre>\n<p>In this code, checking that value is present or not by getting all the Names from the enum declaration by using <strong>Enum.GetNames()</strong> method.</p>\n<p>This code will print <code>Not Parsed</code></p>\n<p><strong>Note</strong>: Here, we will not be able to parse any of the integer values. It will only check the values which are defined in the Enum declaration.</p>\n<h2 id=\"conclusion\" style=\"position:relative;\"><a href=\"#conclusion\" aria-label=\"conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Conclusion</h2>\n<p>In this article, We have discussed the mistake we can make using the <code>Enum.TryParse()</code> method. This mistake can hurt and can abnormally terminate our program/application. We can use the ways I have mentioned in this article to overcome so that our program/application can run smoothly.</p>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n  .dark-default-dark {\n    background-color: #1E1E1E;\n    color: #D4D4D4;\n  }\n  .dark-default-dark .mtk4 { color: #569CD6; }\n  .dark-default-dark .mtk1 { color: #D4D4D4; }\n  .dark-default-dark .mtk10 { color: #4EC9B0; }\n  .dark-default-dark .mtk12 { color: #9CDCFE; }\n  .dark-default-dark .mtk11 { color: #DCDCAA; }\n  .dark-default-dark .mtk8 { color: #CE9178; }\n</style>","frontmatter":{"date":"April 28, 2021","updated_date":null,"description":"In this article, I will talk about how Enum.TryParse() works in C# and mistake which we can make while using it.","title":"How Enum.TryParse() works in C#","tags":["C#","Enum"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/51a037c87d4168dfe8b48e7169c2e0ed/ee604/coverimage.png","srcSet":"/static/51a037c87d4168dfe8b48e7169c2e0ed/69585/coverimage.png 200w,\n/static/51a037c87d4168dfe8b48e7169c2e0ed/497c6/coverimage.png 400w,\n/static/51a037c87d4168dfe8b48e7169c2e0ed/ee604/coverimage.png 800w,\n/static/51a037c87d4168dfe8b48e7169c2e0ed/f3583/coverimage.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Hemant Manwani","github":"hemant404","avatar":null}}}}]},"markdownRemark":{"excerpt":"Google has prepared a roadmap to restrict third-party cookies in Chrome. Since 04 January 2024, Chrome has rolled out third-party cookie…","fields":{"slug":"/engineering/identity-impact-of-google-chrome-thirdparty-cookie-restrictions/"},"html":"<p>Google has prepared a roadmap to restrict third-party cookies in Chrome. Since 04 January 2024, Chrome has rolled out third-party cookie restrictions for 1% of stable clients and 20% of Canary, Dev, and Beta clients.</p>\n<p><strong>What does it mean for user authentication?</strong></p>\n<p>On one hand, Google believes third-party cookies are widely used for cross-site tracking, greatly affecting user privacy. Hence, Google wants to phase out (or restrict) supporting third-party cookies in Chrome by early Q2 2025 (subject to regulatory processes).</p>\n<p>On the other hand, Google introduced Privacy Sandbox to support the use cases (other than cross-site tracking and advertising) previously implemented using third-party cookies.</p>\n<p>In this article, we’ll discuss:</p>\n<ul>\n<li>How is user authentication (identity) affected?</li>\n<li>What is Google offering as part of Privacy Sandbox to support various identity use cases when third-party cookies are phased out?</li>\n</ul>\n<h2 id=\"how-is-user-authentication-affected\" style=\"position:relative;\"><a href=\"#how-is-user-authentication-affected\" aria-label=\"how is user authentication affected permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How is User Authentication Affected?</h2>\n<p>Third-party cookie restrictions affect user authentication in three ways, as follows.</p>\n<h3 id=\"external-identity-providers\" style=\"position:relative;\"><a href=\"#external-identity-providers\" aria-label=\"external identity providers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>External Identity Providers</h3>\n<p>If your website or app uses an external Identity Provider (IdP) — like LoginRadius, the IdP sets a third-party cookie when the user authenticates on your app.</p>\n<h3 id=\"web-sso\" style=\"position:relative;\"><a href=\"#web-sso\" aria-label=\"web sso permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Web SSO</h3>\n<p>If you have multiple apps across domains within your organization and authentication is handled using an IdP (internal or external) with web SSO, you already use third-party cookies to facilitate seamless access for each user using a single set of credentials.</p>\n<p>If you have implemented web SSO with one primary domain and multiple sub-domains of the primary domain, third-party cookie restrictions may not apply. For now, Google doesn’t consider the cookies set by sub-domains as third-party cookies, although this stance may change in the future.</p>\n<p>For example, you have apps at <code>example.com</code>, <code>travel.example.com</code>, <code>stay.example.com</code>, and web SSO is handled by <code>auth.example.com</code>. In this case, third-party cookie restrictions don’t apply.</p>\n<h3 id=\"federated-sso\" style=\"position:relative;\"><a href=\"#federated-sso\" aria-label=\"federated sso permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Federated SSO</h3>\n<p>Federated SSO is similar to, albeit different from, web SSO. It can handle multiple IdPs and applications—aka., Service Providers (SPs)—spanning multiple organizations. It can also implement authentication scenarios that are usually implemented through web SSO.</p>\n<p>Usually, authentication is handled on a separate pop-up or page when the user wants to authenticate rather than on the application or website a user visits. </p>\n<p>For example, you already use federated SSO if you facilitate authentication for a set of apps through multiple social identity providers as well as traditional usernames and passwords.</p>\n<blockquote>\n<p><strong>Note</strong>: It is also possible to store tokens locally, not within cookies. In this case, third-party cookie restrictions won’t affect token-based authentication. However, the restrictions still affect authentication where tokens are stored within third-party cookies (a common and secure method).</p>\n</blockquote>\n<h2 id=\"chromes-alternatives-for-third-party-cookies\" style=\"position:relative;\"><a href=\"#chromes-alternatives-for-third-party-cookies\" aria-label=\"chromes alternatives for third party cookies permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Chrome’s Alternatives for Third-Party Cookies</h2>\n<p>Google has been developing alternative features and capabilities for Chrome to replace third-party cookies as part of its Privacy Sandbox for Web initiative.</p>\n<p>Specific to authentication, Google recommends the following:</p>\n<ol>\n<li>Cookies Having Independent Partitioned State (CHIPS)</li>\n<li>Storage Access API</li>\n<li>Related Website Sets</li>\n<li>Federated Credential Management (FedCM) API</li>\n</ol>\n<h3 id=\"cookies-having-independent-partitioned-state-chips\" style=\"position:relative;\"><a href=\"#cookies-having-independent-partitioned-state-chips\" aria-label=\"cookies having independent partitioned state chips permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cookies Having Independent Partitioned State (CHIPS)</h3>\n<p><a href=\"https://developers.google.com/privacy-sandbox/3pcd/chips\">CHIPS</a> are a restricted way of setting third-party cookies on a top-level site without making them accessible on other top-level sites. Thus, they limit cross-site tracking and enable specific cross-site functionalities, such as maps, chat, and payment embeds.</p>\n<p>For example, a user visits <code>a.com</code> with a map embed from <code>map-example.com</code>, which can set a partitioned cookie that is only accessible on a.com. </p>\n<p>If the user visits <code>b.com</code> with a map embed from <code>map-example.com</code>, it cannot access the partitioned cookie set on <code>a.com</code>. It has to create a separate partitioned cookie specific to <code>b.com</code>, thus blocking cross-site tracking yet allowing limited cross-site functionality.</p>\n<p>You should specifically opt for partitioned cookies (CHIPS), which are set with partitioned and secure cookie attributes.</p>\n<p>If you’re using an external identity provider for your application, CHIPS is a good option to supplant third-party cookie restrictions. </p>\n<p>However, CHIPS may not be ideal if you have a web SSO or federated SSO implementation. It creates separate partitioned cookies for each application with a separate domain, which can increase complexity and create compatibility issues.</p>\n<h3 id=\"storage-access-api\" style=\"position:relative;\"><a href=\"#storage-access-api\" aria-label=\"storage access api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Storage Access API</h3>\n<p>With <a href=\"https://developers.google.com/privacy-sandbox/3pcd/storage-access-api\">Storage Access API</a>, you can access the local storage in a third-party context through iframes, similar to when users visit it as a top-level site in a first-party context. That is, it gives access to unpartitioned cookies and storage.</p>\n<p>Storage Access API requires explicit user approval to grant access, similar to locations, camera, and microphone permissions. If the user denies access, unpartitioned cookies and storage won’t be accessible in a third-party context.</p>\n<p>It is most suitable when loading cross-site resources and interactions, such as:</p>\n<p>Verifying user sessions when allowing interactions on an embedded social post or providing personalization for an embedded video.\nEmbedded documents requiring user verification status to be accessible.</p>\n<p>As it requires explicit user approval, it is advisable to use Storage Access API when you can’t implement an identity use case with the other options.</p>\n<h3 id=\"related-website-sets\" style=\"position:relative;\"><a href=\"#related-website-sets\" aria-label=\"related website sets permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Related Website Sets</h3>\n<p>With <a href=\"https://developers.google.com/privacy-sandbox/3pcd/related-website-sets\">Related Website Sets</a>, you can declare a <code>primary</code> website and <code>associatedSites</code> for limited purposes to grant third-party cookie access and local storage for a limited number of sites.</p>\n<p>Chrome automatically recognizes related website sets declared, accepted, and maintained in this open-source GitHub repository: <a href=\"https://github.com/GoogleChrome/related-website-sets\">Related Website Sets</a></p>\n<p>It provides access through Storage Access API directly without prompting for user approval, but only after the user interacts with the relevant iframe.</p>\n<p>It is important to declare a limited number of domains in related website sets that are meaningful and used for specific purposes. Google may block or suspend any exploitative use of this feature.</p>\n<p>The top-level site can also request approval for specific cross-site resources and scripts to Storage Access API using <code>resuestStorageAccessFor()</code> API.</p>\n<p>If you’re using an external identity provider for your web application, you can declare the domain of the identity provider in the related set to ensure limited third-party cookies and storage access to the identity provider, thus ensuring seamless user authentication.</p>\n<p>Related Website Sets can also work to supplement third-party cookie restrictions in web SSO and federated SSO if the number of web applications (or domains) is limited.</p>\n<h3 id=\"federated-credential-management-fedcm-api\" style=\"position:relative;\"><a href=\"#federated-credential-management-fedcm-api\" aria-label=\"federated credential management fedcm api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Federated Credential Management (FedCM) API</h3>\n<p>FedCM API enables federated SSO without third-party cookies.</p>\n<p>With FedCM API, a user follows these steps for authentication:</p>\n<ol>\n<li>The User navigates to a Service Provider (SP) — aka., Relying Party (RP)</li>\n<li>As the user requests to authenticate, the SP requests the browser through FedCM API to initiate authentication.</li>\n<li>The browser displays a list of available identity providers (supported by the RP), such as social IdPs like Google, Apple, LinkedIn, and Facebook, or other OAuth IdPs like LoginRadius.</li>\n<li>Once the user selects an IdP, the browser communicates with the IdP. Upon valid authentication, the IdP generates a secure token.\nThe browser delivers this secure token to the RP to facilitate user authorization.</li>\n</ol>\n<p>You can access a user demo of FedCM here: <a href=\"https://fedcm-rp-demo.glitch.me/\">FedCM</a>. </p>\n<p>For more information about implementing federated SSO with FedCM API, go through the <a href=\"https://developers.google.com/privacy-sandbox/3pcd/fedcm-developer-guide\">FedCM developer guide</a>.</p>\n<h2 id=\"how-is-loginradius-preparing-for-the-third-party-cookie-phase-out\" style=\"position:relative;\"><a href=\"#how-is-loginradius-preparing-for-the-third-party-cookie-phase-out\" aria-label=\"how is loginradius preparing for the third party cookie phase out permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How is LoginRadius Preparing for the Third-party Cookie Phase-out?</h2>\n<p>Firstly, we’re committed to solving our customers' user identity pain points — and preparing for the third-party cookies phase-out is no different.</p>\n<p>We’ll implement the most relevant and widely useful solutions to facilitate a smooth transition for our customers.</p>\n<p>Please subscribe to our blog for more information. We’ll update you on how we help with the third-party cookie phase-out.</p>\n<h2 id=\"in-conclusion\" style=\"position:relative;\"><a href=\"#in-conclusion\" aria-label=\"in conclusion permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>In Conclusion</h2>\n<p>The proposed changes to phase out third-party cookies and suggested alternatives are evolving as Google has been actively collaborating and discussing changes with the border community.</p>\n<p>Moreover, browsers like Firefox, Safari, and Edge may approach restricting third-party cookies differently than Google does.</p>\n<p>From LoginRadius, we’ll keep you updated on what we’re doing as a leading Customer Identity and Access Management (CIAM) vendor to prepare for the third-party cookie phase-out.</p>\n<h2 id=\"glossary\" style=\"position:relative;\"><a href=\"#glossary\" aria-label=\"glossary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Glossary</h2>\n<p><strong>Top-level site</strong>: It is the primary site a user has visited.</p>\n<p><strong>First-party cookie</strong>: A cookie set by the top-level site.</p>\n<p><strong>Third-party cookie</strong>: A cookie set by a domain other than the top-level site. For example, let’s assume that a user has visited <code>a.com</code>, which might use an embed from <code>loginradius.com</code> to facilitate authentication. If <code>loginradius.com</code> sets a cookie when the user visits <code>a.com</code>, it is called a third-party cookie as the user hasn’t directly visited <code>loginradius.com</code>.</p>\n<h2 id=\"references\" style=\"position:relative;\"><a href=\"#references\" aria-label=\"references permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>References</h2>\n<ul>\n<li><a href=\"https://developers.google.com/privacy-sandbox/3pcd/prepare/prepare-for-phaseout\">Changes to Chrome's treatment of third-party cookies</a></li>\n<li><a href=\"https://developers.google.com/privacy-sandbox/3pcd/guides/identity\">Check the impact of the third-party cookie changes on your sign-in workflows</a></li>\n</ul>\n<style class=\"grvsc-styles\">\n  .grvsc-container {\n    overflow: auto;\n    -webkit-overflow-scrolling: touch;\n    padding-top: 1rem;\n    padding-top: var(--grvsc-padding-top, var(--grvsc-padding-v, 1rem));\n    padding-bottom: 1rem;\n    padding-bottom: var(--grvsc-padding-bottom, var(--grvsc-padding-v, 1rem));\n    border-radius: 8px;\n    border-radius: var(--grvsc-border-radius, 8px);\n    font-feature-settings: normal;\n  }\n  \n  .grvsc-code {\n    display: inline-block;\n    min-width: 100%;\n  }\n  \n  .grvsc-line {\n    display: inline-block;\n    box-sizing: border-box;\n    width: 100%;\n    padding-left: 1.5rem;\n    padding-left: var(--grvsc-padding-left, var(--grvsc-padding-h, 1.5rem));\n    padding-right: 1.5rem;\n    padding-right: var(--grvsc-padding-right, var(--grvsc-padding-h, 1.5rem));\n  }\n  \n  .grvsc-line-highlighted {\n    background-color: var(--grvsc-line-highlighted-background-color, transparent);\n    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, transparent);\n  }\n  \n</style>","frontmatter":{"date":"July 08, 2024","updated_date":null,"description":"Google Chrome has planned to phase out third-party cookies, which will affect different website functionalities depending on third-party cookies. This blog focuses on how this phase-out affects identity and user authentication and discusses alternatives for overcoming challenges.","title":"How Chrome’s Third-Party Cookie Restrictions Affect User Authentication?","tags":["Identity","Cookies","Chrome"],"pinned":null,"coverImage":{"childImageSharp":{"fluid":{"aspectRatio":1.5037593984962405,"src":"/static/eb7396060c0adc430dbed2d04b63d431/ee604/third-party-cookies-phaseout-chrome.png","srcSet":"/static/eb7396060c0adc430dbed2d04b63d431/69585/third-party-cookies-phaseout-chrome.png 200w,\n/static/eb7396060c0adc430dbed2d04b63d431/497c6/third-party-cookies-phaseout-chrome.png 400w,\n/static/eb7396060c0adc430dbed2d04b63d431/ee604/third-party-cookies-phaseout-chrome.png 800w,\n/static/eb7396060c0adc430dbed2d04b63d431/f3583/third-party-cookies-phaseout-chrome.png 1200w","sizes":"(max-width: 800px) 100vw, 800px"}}},"author":{"id":"Raghunath Reddy","github":"raghunath-r-a","avatar":null}}}},"pageContext":{"limit":6,"skip":60,"currentPage":11,"type":"//engineering//","numPages":52,"pinned":"17fa0d7b-34c8-51c4-b047-df5e2bbaeedb"}},"staticQueryHashes":["1171199041","1384082988","2100481360","23180105","528864852"]}