<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rafael Assad on Medium]]></title>
        <description><![CDATA[Stories by Rafael Assad on Medium]]></description>
        <link>https://medium.com/@rafaassad?source=rss-bb329869906a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oJX3QD5Mw2Ch9Lh8</url>
            <title>Stories by Rafael Assad on Medium</title>
            <link>https://medium.com/@rafaassad?source=rss-bb329869906a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 16:24:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rafaassad/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrate Datadog with NextJS]]></title>
            <link>https://rafaassad.medium.com/integrate-datadog-with-nextjs-591fe126e339?source=rss-bb329869906a------2</link>
            <guid isPermaLink="false">https://medium.com/p/591fe126e339</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[datadog]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Rafael Assad]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 18:35:37 GMT</pubDate>
            <atom:updated>2021-07-06T18:35:37.921Z</atom:updated>
            <content:encoded><![CDATA[<h4>- an easy guide to integrate Datadog with your NextJs app</h4><figure><img alt="datadog plus nextjs logos" src="https://cdn-images-1.medium.com/max/1024/1*Gs495asuqJC0WVbMhWKmtQ.jpeg" /></figure><blockquote>Recently I needed to monitor an application on NextJs, using the Datadog website.</blockquote><blockquote>Since the NextJs framework is a relatively new technology on the market, I had a hard time finding information on how to integrate these two applications.</blockquote><blockquote>So I decided to write about the process, to help other fellow developers.</blockquote><h3>RUM Browser Monitoring</h3><p>Datadog Real User Monitoring (RUM) enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users.</p><h3>Setup</h3><p>To set up Datadog RUM browser monitoring:</p><ol><li>In Datadog, navigate to the <a href="https://app.datadoghq.com/rum/list">Real User Monitoring page</a> and click the <strong>New Application</strong> button.</li><li>Enter a name for your application and click <strong>Generate Client Token</strong>. This generates a clientToken and an applicationId for your application.</li><li>Setup the Datadog RUM SDK via <a href="https://www.npmjs.com/package/@datadog/browser-rum#npm">npm</a> or via one of the hosted versions: <a href="https://www.npmjs.com/package/@datadog/browser-rum#cdn-async">CDN async</a> or <a href="https://www.npmjs.com/package/@datadog/browser-rum#cdn-sync">CDN sync</a>.</li><li>Deploy the changes to your application. Once your deployment is live, Datadog collects events from user browsers.</li><li>Visualize the <a href="https://docs.datadoghq.com/real_user_monitoring/data_collected/">data collected</a> using Datadog <a href="https://docs.datadoghq.com/real_user_monitoring/dashboards/">dashboards</a>.</li></ol><h3>Installing the Library</h3><p>Add <a href="https://www.npmjs.com/package/@datadog/browser-rum">@datadog/browser-rum</a> to your package.jsonwith</p><p>&gt; npm i @datadog/browser-rum</p><p>or other package manager you use.</p><p>Then initialize it with:</p><figure><img alt="datadog init" src="https://cdn-images-1.medium.com/max/459/1*4o845sq3ByIWcfOEWEbaDQ.jpeg" /></figure><blockquote>Sounds easy, doesn&#39;t it? Here&#39;s the catch, due to the type of rendering that is used in NextJs, any value used in RUM initialization will return as <strong>undefined</strong>! We&#39;ll talk more about it below.</blockquote><h3>Server Side Rendering (SSR)</h3><p>As NextJs renders on the server side, and that has a number of advantages, but that doesn&#39;t matter now, <strong>by default all environment variables loaded through </strong><strong>.env.local are only available in the Node.js environment, meaning they won&#39;t be exposed to the browser.</strong></p><p>In order to expose a variable to the browser you have to prefix the variable with NEXT_PUBLIC_. For example:</p><p>Instead using: <strong>“applicationId: process.env.DATADOG_APPLICATION_ID”,</strong></p><p>Use: <strong>“applicationId: process.env.NEXT_PUBLIC_DATADOG_APPLICATION_ID”</strong></p><p>This loads process.env.NEXT_PUBLIC_DATADOG_APPLICATION_ID into the Node.js environment automatically, allowing you to use it anywhere in your code. The value will be inlined into JavaScript sent to the browser because of the NEXT_PUBLIC_ prefix. This inlining occurs at build time, so your various NEXT_PUBLIC_ envs need to be set when the project is built.</p><blockquote>So that’s it, now just follow the monitoring by the Datadog website</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OMOkjZOzpoK-FQ3ytq3TA.png" /></figure><h3>References</h3><p><a href="https://www.npmjs.com/package/@datadog/browser-rum">npm RUM Browser Monitoring</a></p><p><a href="https://nextjs.org/docs/basic-features/environment-variables">Basic features: Environment Variables | Next.js</a></p><p>Hope it helps!</p><p>Cheers,</p><p>Rafael.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=591fe126e339" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>