<?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 Félix on Medium]]></title>
        <description><![CDATA[Stories by Félix on Medium]]></description>
        <link>https://medium.com/@marcot_f?source=rss-c6d06163d48e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*liCd0-FGMNUA5xffi-nhDQ.jpeg</url>
            <title>Stories by Félix on Medium</title>
            <link>https://medium.com/@marcot_f?source=rss-c6d06163d48e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:19:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcot_f/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[Build once, deploy many with NuxtJS]]></title>
            <link>https://medium.com/@marcot_f/build-once-deploy-many-with-nuxtjs-2795d457e5f3?source=rss-c6d06163d48e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2795d457e5f3</guid>
            <category><![CDATA[nuxtjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Félix]]></dc:creator>
            <pubDate>Tue, 22 Sep 2020 07:57:18 GMT</pubDate>
            <atom:updated>2020-09-23T19:41:09.087Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Build Once, Deploy Many With NuxtJS</h3><h4>How to use environment variables in runtime with NuxtJS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u9ahZaMh0UBK2Thihpyo3w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@arianismmm?utm_source=medium&amp;utm_medium=referral">Arian Darvishi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The context</h3><p>In the age of cloud computing and containers, developers want to build once and deploy many instances of their app. But sometimes, you need to tweak the configuration to make things work, usually with what is called <strong><em>ENV VARIABLES</em></strong><em>.</em></p><p>Sadly, when working with an SSR framework like NuxtJS, you can’t customize env variables once the app is built. So, to change the content, you have to rebuild the whole app which is against the <a href="https://12factor.net/">12Factor</a> app design.</p><p><a href="https://12factor.net/">The Twelve-Factor App</a></p><h3>Introducing runtime config</h3><p><strong>NuxtJS v2.13 🚀</strong>introduced two new options in the <em>nuxt.config.js</em> file:</p><ol><li><strong>publicRuntimeConfig</strong>, available on client and server</li><li><strong>privateRuntimeConfig</strong>, available only on the server</li></ol><p>No need anymore for many configurations file, Webpack chaos, or for a slow and complex Dockerfile… but you still need to tweak <em>just a little </em>to link your env variables or <strong><em>.env</em></strong> file to your app.</p><h4>Configuration</h4><p>To define your runtime config, you just need to add <strong>publicRuntimeConfig </strong>and <strong>privateRuntimeConfig</strong> to the <em>nuxt.config.js</em> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d50df2c717e316c0e36a1e73088f16e0/href">https://medium.com/media/d50df2c717e316c0e36a1e73088f16e0/href</a></iframe><p>To work with env, you’ll have to map all your env variables to the NuxtJS config file. Using an <strong>.<em>env</em></strong> file can be done easily thanks to the <strong>dotenv</strong> integration. Your variables will be accessible in your <strong><em>nuxt.config.js</em></strong><em> </em>with process.env.VARIABLE_NAME.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a52c369f01ed1f9b7532eaf2c9375f5/href">https://medium.com/media/0a52c369f01ed1f9b7532eaf2c9375f5/href</a></iframe><h4>Usage</h4><p>Now that NuxtJS knows our env variables, we can call them anywhere from context (including pages, store, and plugins) with <strong>$config</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e89a79f060acc4016f7458d3a76d73e/href">https://medium.com/media/1e89a79f060acc4016f7458d3a76d73e/href</a></iframe><h3>Conclusion</h3><p>After defining your env variables, you just need to build your app and run it with your variables defined.</p><pre>npm run build<br>API_SECRET=foo VERSION_ID=beta npm run start</pre><p>You can now build your app once, and deploy it in production, staging, or whatever you name your environment with easy settings. And of course, it works well with docker and docker-compose 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2795d457e5f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>