<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Filip</title>
    <description>The latest articles on DEV Community by Filip (@0x96f).</description>
    <link>https://dev.to/0x96f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F90940%2Feff8b017-3339-4ab6-8d90-d2fbea9664ca.jpg</url>
      <title>DEV Community: Filip</title>
      <link>https://dev.to/0x96f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0x96f"/>
    <language>en</language>
    <item>
      <title>0x96f: A simple and pleasant dark theme</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Thu, 20 Feb 2025 23:59:22 +0000</pubDate>
      <link>https://dev.to/0x96f/0x96f-a-simple-and-pleasant-dark-terminal-theme-2d8m</link>
      <guid>https://dev.to/0x96f/0x96f-a-simple-and-pleasant-dark-terminal-theme-2d8m</guid>
      <description>&lt;p&gt;Hello everyone! I have made a simple and pleasant dark terminal theme. It is something I wanted to do for a long time since I liked certain things from multiple themes but none of them caught my eye. I wanted to create a theme that would be easy on the eyes and aesthetically pleasing. Not too bright, not too dark.&lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts and feedback! Feel free to try it out and let me know if you have any suggestions for improvements. Or fork it and do whatever you want with it 😁!&lt;/p&gt;

&lt;p&gt;The theme for terminals is available &lt;a href="https://github.com/filipjanevski/0x96f-term-theme" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I also have a theme for Zed, which you can find at &lt;a href="https://github.com/filipjanevski/zed-theme" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>terminal</category>
      <category>zed</category>
      <category>themes</category>
    </item>
    <item>
      <title>My thoughts on AI for developers</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Fri, 12 Apr 2024 11:31:06 +0000</pubDate>
      <link>https://dev.to/0x96f/my-thoughts-on-ai-for-developers-49pd</link>
      <guid>https://dev.to/0x96f/my-thoughts-on-ai-for-developers-49pd</guid>
      <description>&lt;p&gt;I have been a developer for 6 years now (not very long) and I have enjoyed every minute of it. Even thought it was tough at times, I still wanted to continue. When I started my career (even when I was in university) there were tools to automate some of the tedious stuff when writing code. For example, I remember discovering IntelliJ code generation tool for generating constructors, getters and setters. Even having that, most of the time I wanted to write them on my own to know them when I don't have this tool available.&lt;/p&gt;

&lt;p&gt;When AI started getting popular, I approached it pretty conservatively, even though I really like testing new things. I chose this approach because I didn't see the value that it brings at the time. But recently I gave in (since I can't escape it, it's everywhere) and decided to try a few tools to aid me when I am developing. I wasn't sure what to use since there is a lot to choose from (and I wanted to give AI a fair shot) so I tried with the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Github Copilot&lt;/li&gt;
&lt;li&gt;ChatGPT&lt;/li&gt;
&lt;li&gt;Claude 3&lt;/li&gt;
&lt;li&gt;Codeium&lt;/li&gt;
&lt;li&gt;Sourcegraph Cody&lt;/li&gt;
&lt;li&gt;Local LLMs (with ollama)

&lt;ul&gt;
&lt;li&gt;Codellama&lt;/li&gt;
&lt;li&gt;Mixtral&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;At first I was impressed as it was far better than I expected. Thay all offered very useful tools such as code completion, explain code, generate tests, refactor code, etc. It was far from the IntelliJ code generation tool that I know.&lt;/p&gt;

&lt;p&gt;Having said all that, I still think they suck. Why? Let's start with the downsides.&lt;/p&gt;

&lt;p&gt;First are the "hallucinations". When generating a piece of code, often they will imagine a library that doesn't exist but resembles a couple of existing ones. This happened more often than I expected. Also, sometimes the code that it suggests is just incorrect. My point is that by the time the code generates, and you make the necessary tweaks and corrections, you could have written it by yourself.&lt;/p&gt;

&lt;p&gt;The second is that it just makes coding a lot less fun. I enjoy sitting down with a cup of coffee and just writing some code. When I get stuck, I never see it as a problem or get discouraged, I see it as a challenge to learn something new. So why waste an afternoon writing code when you can generate so code with AI and just fix it up and ship it? It kills creativity, it leads to a lack of deeper understanding of the language and tools you are using (and also the thing you are developing).&lt;/p&gt;

&lt;p&gt;The biggest problem I see is that developers, especially young developers at the start of their careers, rely too much on AI. I get the value it brings when it comes to helping with the tedious tasks that are repeated in almost every project, but constantly using it while developing for everything is just wrong. An inexperienced developer can't tell if the code generated is right or wrong. It may be right for some simple thing that he will try, but it might cause more problems down the line. Even I noticed that after using AI for a couple of months, I started to rely too much on it. An example of this is when the Copilot extension crashed. I found myself waiting about 5–6 seconds for the autocomplete of a simple function call because I was becoming lazy (to be honest, I could have written it in the same time I waited).&lt;/p&gt;

&lt;p&gt;Just to be clear, I am not dismissing AI outright, but I think we are still not on the level as everyone is making it out to be. I think there is a lot of potential, but we are still not there yet. These are just my thoughts, I would love to hear what other people think of this.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Labeled statements - the forgotten JS feature</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Thu, 21 Sep 2023 19:06:32 +0000</pubDate>
      <link>https://dev.to/0x96f/labeled-statements-the-forgotten-js-feature-169o</link>
      <guid>https://dev.to/0x96f/labeled-statements-the-forgotten-js-feature-169o</guid>
      <description>&lt;p&gt;For years I have been following Svelte but never got around to trying it out. Recently I found some free time, so I decided to look into it. While going through the docs I found an interesting JS feature that I have forgotten about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This feature is used in Svelte to power reactive declarations, which are re-computed whenever the variables declared into the statement change. In the case above &lt;code&gt;doubled&lt;/code&gt; will be re-computed whenever &lt;code&gt;count&lt;/code&gt; changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are &lt;strong&gt;labeled statements&lt;/strong&gt;?
&lt;/h2&gt;

&lt;p&gt;Lets take a step back. What is a labeled statement? According to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A labeled statement is any statement that is prefixed with an identifier. You can jump to this label using a break or continue statement nested within the labeled statement.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically it is sort of a &lt;code&gt;goto&lt;/code&gt; statement for loops. For example if we want to exit a nested loop we can use it in the following way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;loopX&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt; &lt;span class="nx"&gt;loopX&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we can exit the parent loop from the child loop by just using the &lt;code&gt;break&lt;/code&gt; statement with the label that we want to break on.&lt;/p&gt;

&lt;p&gt;Labeled statements are not just exclusive to loops, they can also be used with &lt;code&gt;if&lt;/code&gt; statements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;outerIf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt; &lt;span class="nx"&gt;outerIf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// This will not log&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It’s rare that you will need to use a JavaScript label. In fact, you can lead a very fulfilling career without ever knowing that this exists. However, you are now able to apply it if you happen to come across a situation where it is useful.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Benchmarking web servers in different languages</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Wed, 18 Jan 2023 14:12:32 +0000</pubDate>
      <link>https://dev.to/0x96f/benchmarking-web-servers-in-different-languages-202l</link>
      <guid>https://dev.to/0x96f/benchmarking-web-servers-in-different-languages-202l</guid>
      <description>&lt;p&gt;Being mainly a JS developer I often find myself testing out new frameworks (new ones pop up every week or so) to find what works best for the next project I do. I mostly worked and tested frontend frameworks, but recently I wanted to try backend development. So I started to look at different options for my next project.&lt;/p&gt;

&lt;p&gt;Since I worked only with NodeJS so far I wanted to see how it compares to different JS runtimes (Deno and Bun) and to different languages. So for my research, I chose to test Deno, Bun, Go, Go and Fiber, Rust, and Actix against the ones I know (Node and Express).&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;For testing I set everything on my M2 Macbook and installed NodeJS, Deno, Bun, Go, and Rust. The setup was painless for all of them since for everything you just need to run a single command from their website and you are good to go.&lt;/p&gt;

&lt;p&gt;I also used a tool called &lt;code&gt;wrk&lt;/code&gt; to run the tests. This is an amazing tool to benchmark HTTP requests to your server. I ran it with the following configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;8 threads&lt;/li&gt;
&lt;li&gt;256 concurrent requests&lt;/li&gt;
&lt;li&gt;30-second test duration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I created the simplest web server for every language (+framework) I could find and ran the tests 10 times with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wrk &lt;span class="nt"&gt;-t8&lt;/span&gt; &lt;span class="nt"&gt;-c256&lt;/span&gt; &lt;span class="nt"&gt;-d30s&lt;/span&gt; http://127.0.0.1:8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;After running the results I found some interesting stuff. While I expected Go and Rust to beat all the JS runtimes that didn't happen. Deno was almost as good as Actix, and Bun almost beat Go for the top spot. Sadly NodeJS fell well behind all of them with the worst being Express. Express came dead last being over 10 times slower than Bun, almost 6 times slower than Deno and 5 times slower than raw NodeJS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While this is in no way a comprehensive comparison it gives me an idea of what to expect when choosing the technology for my next project. The results here may be different depending on what I need for my project. My main takeaway here is that it may be time to start moving away from NodeJS, at least when it comes to backend development.&lt;/p&gt;

&lt;p&gt;All the results and scripts can be found &lt;a href="https://github.com/filipjanevski/server-runtime-benchmark" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>discuss</category>
      <category>performance</category>
    </item>
    <item>
      <title>My top 3 new JavaScript features that made my life better</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Thu, 18 Mar 2021 11:04:08 +0000</pubDate>
      <link>https://dev.to/0x96f/my-top-3-new-javascript-features-that-made-my-life-better-1boo</link>
      <guid>https://dev.to/0x96f/my-top-3-new-javascript-features-that-made-my-life-better-1boo</guid>
      <description>&lt;p&gt;I've been working with JavaScript for the last 3-4 years but the last year I've seen massive improvement in the language. In my opinion ES2020 was a huge step in the right direction and ES2021 seems to have some great stuff to offer too. With ES2020 we have seen some very useful features added but I will talk about my top 3 that saved me countless hours. My top 3 (relatively) new features are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic imports&lt;/li&gt;
&lt;li&gt;Optional Chaining&lt;/li&gt;
&lt;li&gt;Nullish Coalescing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Dynamic imports
&lt;/h2&gt;

&lt;p&gt;Until now for every library, component, module or anything else you wanted to use in your code you needed to import it first at the top of your file. Even if it is used only in certain situations (like if the user clicks a button something shows up) the code will be imported. This could have a huge impact on performance because you load a lot of things you don't use. For this dynamic imports have been a lifesaver. With dynamic imports you can lazily import a module at runtime. This means you can delay the loading of non-essential modules until they are required.&lt;/p&gt;

&lt;p&gt;For example instead of statically loading a huge library at the top of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;LargeLib&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;large-lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can load it when it is required:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;LargeLib&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;large-lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// ----- do something with the lib -----&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optional Chaining
&lt;/h2&gt;

&lt;p&gt;This has been by far the most popular and talked about feature of ES2020. And in my opinion it deserves the praise that it gets because it is a real lifesaver. Optional chaining in a feature that allows you to call a deeply nested property without throwing an error if the parent property is undefined.&lt;/p&gt;

&lt;p&gt;In the past you needed to check every properly down to the one you need. For example we want to get the city of the company:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Old way&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Optional chaining&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;company&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the code look a lot cleaner and more readable. With one look you can see exactly what you wanted to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nullish Coalescing
&lt;/h2&gt;

&lt;p&gt;Nullish coalescing is also one of the more popular new features. In the past when you wanted to set a default value to a property when it is undefined. Until now the common way of doing that was with the OR (&lt;code&gt;||&lt;/code&gt;) operator. Let's do this with an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animationDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above we want &lt;code&gt;animationDuration&lt;/code&gt; to be set to &lt;code&gt;duration&lt;/code&gt; only if duration is defined. But the problem here is when we want to se it to 0 it will default to 500. This happens because 0 is considered a falsy value and there for the OR operator takes the right one. We can fix this with type checking but that just makes the code messy. To fix this in a more elegant we can fix this with the nullish coalescing operator (&lt;code&gt;??&lt;/code&gt;). It only checks if the value is &lt;code&gt;undefined&lt;/code&gt; or &lt;code&gt;null&lt;/code&gt;. All we have to do is replace the OR operator with the nullish coalescing operator and now we can use 0 as a valid value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This ...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animationDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ... becomes this&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animationDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;JavaScript is truly becoming a modern and elegant language. It is amazing and wonderful to see how JavaScript came from a language which was booed on, to one of the strongest and most versatile language. There is much more to write about, so many new and very useful features, but I decided to keep it short and sweet.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Fish Shell - Is it time to replace Bash and Zsh ?</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Mon, 08 Feb 2021 17:05:05 +0000</pubDate>
      <link>https://dev.to/0x96f/fish-shell-is-it-time-to-replace-bash-and-zsh-2bbc</link>
      <guid>https://dev.to/0x96f/fish-shell-is-it-time-to-replace-bash-and-zsh-2bbc</guid>
      <description>&lt;h2&gt;
  
  
  Bash and Zsh
&lt;/h2&gt;

&lt;p&gt;Bash has been around for a very long time (since 1989) and if you open up a Terminal on Linux or Mac, you’ve seen Bash since it has been the shell of choice for a very long time. You can run commands, create aliases for commands, define and export variables, make functions and that’s about it. &lt;/p&gt;

&lt;p&gt;Zsh is not much different from Bash, in fact it is an extended version of Bourne Shell (the same shell that Bash is based on) with plenty of new features, and support for plugins and themes. One of the coolest things about Zsh is color customization. You can easily change the theme and color of your shell just by using a framework called &lt;a href="https://ohmyz.sh/" rel="noopener noreferrer"&gt;Oh My Zsh&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But both Bash and Zsh are limited in many ways. They both lack modern features like tab completions and autosuggestion, and can be a bit harder to configure if you are a beginner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you should use Fish instead
&lt;/h2&gt;

&lt;p&gt;Fish is the most user-friendly command line shell in my opinion. It has a number of smart features and improvements when compared to other shells, namely Bash and Zsh. When you first start typing in Fish, you will immediately notice that it has an autosuggestion feature where, as you type, Fish will suggest commands to you based on your shell history. Also as you are typing you will notice the commands will change color.  When the command is not complete it will be red meaning it is not a valid command and once it is valid it will turn blue. For example when you type &lt;code&gt;c&lt;/code&gt; it will be in red because it is not a command, but when you add a &lt;code&gt;d&lt;/code&gt; to run &lt;code&gt;cd&lt;/code&gt; it will turn blue because &lt;code&gt;cd&lt;/code&gt; is a valid command. Also Fish supports 24 bit true color and it is customizable so you can make it look however you want.&lt;/p&gt;

&lt;p&gt;Tab completions in Fish are really quite amazing. You don't need to add any plugins or hack Fish in any weird way to get tab completion to work either, unlike with Bash or Zsh. As you type a command, hit &lt;code&gt;TAB&lt;/code&gt; and you will be presented a list of possible commands. If you are unsure of a flag for a command, you can hit &lt;code&gt;TAB&lt;/code&gt; while typing flags, and you will  get a list of possible flags. So if you type &lt;code&gt;ls -&lt;/code&gt; and then hit &lt;code&gt;TAB&lt;/code&gt;,  you will get the flags for &lt;code&gt;ls&lt;/code&gt;.  Fish gets this data from the man-pages installed on your machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring the Fish shell
&lt;/h2&gt;

&lt;p&gt;Fish is configurable although for most users the default configuration will do the job very well. But for those that love to hack on things, Fish can be configured easily without ever needing to edit the config files manually. There is a built-in web configuration tool that you can launch with &lt;code&gt;fish_config&lt;/code&gt;.  This will open a page in your browser where you select the features and themes that you want. When you're done you just save the configuration and voila! Another easy way to configure Fish is with the &lt;a href="https://github.com/oh-my-fish/oh-my-fish" rel="noopener noreferrer"&gt;Oh My Fish&lt;/a&gt; framework. Oh My Fish provides an infrastructure to allow you to install packages that extend or modify the look of Fish. It's easy to install with just one command in the terminal, and it's easy to use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scripting in the Fish shell
&lt;/h2&gt;

&lt;p&gt;Fish is fully scriptable. Its syntax is simple, clean and consistent. It has a sane syntax where things like &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;case&lt;/code&gt;  statements no longer have to be closed with &lt;code&gt;fi&lt;/code&gt; and &lt;code&gt;esac&lt;/code&gt;,  you can just use &lt;code&gt;end&lt;/code&gt;. While the difference in syntax from Bash can be discouraging for some, it is really easy to get the hang of it and feels more natural. You can also define universal variables, which are shared instantaneously with all running Fish sessions and persists through shell restarts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons of using Fish shell
&lt;/h2&gt;

&lt;p&gt;Nothing is perfect so Fish has its down sides as well. First it is not compatible with POSIX sh. Depending on how you look at it this can be a positive and a negative thing. This just means that it's a separate language (like Java, Python) rather than an implementation or extension of sh (like Bash, Dash). Some other features are missing like no support for &lt;code&gt;!!&lt;/code&gt;, but you can use the Oh My Fish framework and install the &lt;code&gt;bang-bang&lt;/code&gt; plugin to have this shortcut in the fish Shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Depending on your needs you might be satisfied with Bash or Zsh but even when doing basic tasks the Fish shell can be a lot more helpful than the others. I certainly recommend trying Fish if you haven't already. You will be amazed by all of its advanced features that just work without the need to spend multiple hours on configuration.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>zsh</category>
    </item>
    <item>
      <title>Using CSS Modules with create-react-app</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Tue, 14 Jul 2020 14:22:46 +0000</pubDate>
      <link>https://dev.to/0x96f/using-css-modules-with-create-react-app-22hd</link>
      <guid>https://dev.to/0x96f/using-css-modules-with-create-react-app-22hd</guid>
      <description>&lt;p&gt;Starting a new React project used to be a complicated process that involved setting up a build system, a code transpiler to convert modern JS code to code that is readable by all browsers, and a base directory structure. Create-react-app offers a modern build setup that comes pre-configured with everything we need to start building our React app. One feature is CSS Modules that is available in &lt;code&gt;create-react-app&lt;/code&gt; from version 2 and later.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are CSS Modules ?
&lt;/h2&gt;

&lt;p&gt;Stylesheets in large apps can get quite messy and coming up with new class names for slightly different components can get hard really quick. A CSS module is a CSS file, but with a key difference: by default, when it is imported in a component every class name and animation inside that module is scoped locally to that component. This allows us to use any valid name for our classes, without worrying about conflicts with other class names in our application. In this post I will show you how to get started with CSS Modules and explain what happens when you use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use CSS Modules in CRA ?
&lt;/h2&gt;

&lt;p&gt;To get started you will need an app generated with the &lt;code&gt;create-react-app&lt;/code&gt; package (version 2 or later, but it is recommended to use the latest). To generate a project you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm i create-react-app &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or if you have &lt;code&gt;npx&lt;/code&gt; installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The way that CRA is set up is that to use CSS Modules first we have to rename all the CSS files from &lt;code&gt;[name].css&lt;/code&gt; to &lt;code&gt;[name].module.css&lt;/code&gt; . In the css file any valid class name is acceptable, but it’s recommend to use  &lt;code&gt;camelCase&lt;/code&gt; for classes with more than one word. The reason for this is that we will access these classes later as properties of a JS object (e.g. &lt;code&gt;styles.someProperty&lt;/code&gt;), but it is not enforced (you can access with &lt;code&gt;styles['some-property']&lt;/code&gt;). Next we can look at how to use them in the components. First we need to change the import:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// From&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// To&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.module.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that we are importing something from the CSS file the same way we do from a JS file. This is because during our build step, the compiler would search through the &lt;code&gt;App.module.css&lt;/code&gt; file that we’ve imported, then look through the JavaScript we’ve written and make the &lt;code&gt;.customClass&lt;/code&gt; class accessible via &lt;code&gt;styles.customClass&lt;/code&gt;. Now we can use the classes as properties from the object that we imported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styles&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./App.module.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customClass&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      Hello React!
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that is it, you are ready to use CSS Modules...&lt;/p&gt;

&lt;h2&gt;
  
  
  But why do we need CSS Modules ?
&lt;/h2&gt;

&lt;p&gt;Well as I mentioned in large project coming up with unique class names can be hard. CSS Modules enable you to use the same class wherever you want. Since the compiler handles the CSS it changes all the class names with different unique names in order make them locally available for that component. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Normal class --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"customClass"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- Module class --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"App_customClass__28RXF"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means that we can have the &lt;code&gt;customClass&lt;/code&gt; in multiple CSS files without worrying about conflicts between them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is not the only benefit of CSS Modules. You can find more about them &lt;a href="https://glenmaddern.com/articles/css-modules" rel="noopener noreferrer"&gt;in this great article&lt;/a&gt;. Hope this is helpful and as always - Happy coding.&lt;/p&gt;

</description>
      <category>react</category>
      <category>css</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React and Tailwind CSS Setup</title>
      <dc:creator>Filip</dc:creator>
      <pubDate>Tue, 24 Mar 2020 10:37:53 +0000</pubDate>
      <link>https://dev.to/0x96f/react-and-tailwind-css-setup-51h0</link>
      <guid>https://dev.to/0x96f/react-and-tailwind-css-setup-51h0</guid>
      <description>&lt;p&gt;Hi everyone, I'm Filip and I am a JavaScript developer. This is my first blog post. Hope you like it and I would love to hear what you think of this post and how I can improve my writing in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Terminal / Command Line (e.g. PowerShell on Windows, Zsh on Linux)&lt;/li&gt;
&lt;li&gt;IDE (e.g. VS Code)&lt;/li&gt;
&lt;li&gt;NodeJS - 8.11.3+&lt;/li&gt;
&lt;li&gt;npm - 6.12.1+&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Getting started
&lt;/h2&gt;

&lt;p&gt;First we will install the &lt;code&gt;npx&lt;/code&gt; package globally. This package allows us to execute packages from npm without installing them. When we run this command it downloads the package, executes it and deletes it. We will install it with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i npx &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will create a starter React app using the &lt;code&gt;create-react-app&lt;/code&gt; package with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app my-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a React app in a folder named &lt;code&gt;my-react-app&lt;/code&gt; ( the name is given in the command above ). Now we will change into the directory and install some packages that we need. For now we will need &lt;code&gt;react-router-dom&lt;/code&gt; ( for navigating in the app ), &lt;code&gt;tailwindcss&lt;/code&gt; ( for Tailwind ), &lt;code&gt;autoprefixer&lt;/code&gt; ( for prefixing CSS for different browsers ) and &lt;code&gt;postcss-cli&lt;/code&gt; ( for watching and reloading CSS updates ). We can do this with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-react-app
yarn add react-router-dom tailwindcss autoprefixer postcss-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to see the initial app created so far you can run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app will be started on &lt;code&gt;localhost:3000&lt;/code&gt; and will display the standard new React App screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Setting Up Tailwind &amp;amp; PostCSS
&lt;/h2&gt;

&lt;p&gt;Now we will set up the configurations for Tailwind and PostCSS. First we will initialize Tailwind into our project. We can do this by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a file called &lt;code&gt;tailwind.config.js&lt;/code&gt; with an empty configuration for Tailwind. We can customize this as we want but for now we will leave it as is. Next we will set up the PostCSS config. Fot this we will create the config file manually. You can do this with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;postcss.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a file called &lt;code&gt;postcss.config.js&lt;/code&gt; . Now we can add the configuration for PostCSS in this file. You can copy and paste the following configuration in the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tailwindcss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tailwindcss&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="nf"&gt;tailwindcss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./tailwind.config.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;autoprefixer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can create a global styles file that will import Tailwind in our app. I recommend in the &lt;code&gt;src&lt;/code&gt; folder that we create a folder called &lt;code&gt;styles&lt;/code&gt; that will hold all the global styles that we need. In this folder we can create a file called &lt;code&gt;tailwind.css&lt;/code&gt; or &lt;code&gt;global.css&lt;/code&gt; ( besides tailwind in this file we can add some custom global overrides ). To use Tailwind all we have to do is put the following in the CSS file that we created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c"&gt;/* All other CSS will go here */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Connecting Tailwind, PostCSS, &amp;amp; React
&lt;/h2&gt;

&lt;p&gt;Now we need to modify the starting scripts for the project that are defined in the &lt;code&gt;package.json&lt;/code&gt; file. When we open the file if should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-react-app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"dependencies"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@testing-library/jest-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^4.2.4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@testing-library/react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9.3.2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@testing-library/user-event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.1.2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"autoprefixer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^9.7.5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"postcss-cli"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^16.13.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^16.13.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-router-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^5.1.2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"3.4.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tailwindcss"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^1.2.0"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts test"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts eject"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"eslintConfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-app"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"browserslist"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"production"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;0.2%"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"not dead"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"not op_mini all"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"development"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"last 1 chrome version"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"last 1 firefox version"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"last 1 safari version"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will modify the scripts part of the file with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run watch:css &amp;amp;&amp;amp; react-scripts start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build:css &amp;amp;&amp;amp; react-scripts build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts test"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"eject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"react-scripts eject"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build:css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postcss src/styles/global.css -o src/styles/main.css"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"watch:css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postcss src/styles/global.css -o src/styles/main.css"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we just need to import the CSS file that will be created when the app is built into &lt;code&gt;index.js&lt;/code&gt; ( root of the app ) and we can start using Tailwind in our app. To do this just replace &lt;code&gt;import './index.css';&lt;/code&gt; with &lt;code&gt;import './styles/main.css';&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;And that is it. Now we can start making beautiful React apps with Tailwind. For more info on how to use Tailwind I recommend the &lt;a href="https://tailwindcss.com/docs" rel="noopener noreferrer"&gt;Tailwind documentation&lt;/a&gt; , it is very clear and has lots of examples.&lt;/p&gt;

&lt;p&gt;The code for this tutorial can be found &lt;a href="https://github.com/filipjanevski/react-tailwind-starter" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>tailwindcss</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
