<?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>Forem: Paul McBride</title>
    <description>The latest articles on Forem by Paul McBride (@thepaulmcbride).</description>
    <link>https://forem.com/thepaulmcbride</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%2F174510%2Ff7f58d83-1f37-4812-a026-d5630224cd74.jpeg</url>
      <title>Forem: Paul McBride</title>
      <link>https://forem.com/thepaulmcbride</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/thepaulmcbride"/>
    <language>en</language>
    <item>
      <title>My SaaS Tech Stack</title>
      <dc:creator>Paul McBride</dc:creator>
      <pubDate>Mon, 29 Jun 2020 17:09:58 +0000</pubDate>
      <link>https://forem.com/thepaulmcbride/my-saas-tech-stack-5h78</link>
      <guid>https://forem.com/thepaulmcbride/my-saas-tech-stack-5h78</guid>
      <description>&lt;p&gt;Building software involves a lot of compromise. Everything has pros and cons. In this article I’d like to share what I used to build &lt;a href="https://wecodeni.com"&gt;WeCode NI&lt;/a&gt; and &lt;a href="https://wecoderemote.com"&gt;weCode Remote&lt;/a&gt;. Both job boards are essentially the same and use very similar tech.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosting
&lt;/h2&gt;

&lt;p&gt;When picking a hosting provider, I have a few requirements. Basically I want it to be affordable and convenient. I do not want to be managing a server or worrying about uptime. For most of the work I do these days, a serverless solution works best.&lt;/p&gt;

&lt;p&gt;That's why for hosting, I use &lt;a href="https://vercel.com"&gt;Vercel&lt;/a&gt;. Vercel is a serverless hosting platform with a generous free tier. I can push my code to Github and a few minutes later, it’s live. My pull requests get deployed to staging urls for me to test and I can have multiple environments each with different configurations.&lt;br&gt;
The whole platform is backed by a smart CDN which helps static sites perform even better and ensures that my sites are always snappy and reliable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Framework
&lt;/h2&gt;

&lt;p&gt;When building a job board, server rendered HTML is very important for SEO. It puts you in control of how search engines see your pages.&lt;/p&gt;

&lt;p&gt;My framework of choice is &lt;a href="https://nextjs.org"&gt;Next.js&lt;/a&gt;. Next.js is a fullstack JavaScript framework from the same folks that make Vercel. It can be used to build dynamic sites, static sites, APIs and projects that mix them all together.&lt;/p&gt;

&lt;p&gt;One of the reasons I use Next.js is for its static regeneration feature. I can create a static page at build time but ensure it is always up-to-date by rebuilding in the background. Next.js makes this really easy to do. Check out the homepage or any job page on weCode Remote or WeCode NI to see it in action.&lt;/p&gt;

&lt;p&gt;I use the Next.js API routes to power a GraphQL endpoint. This endpoint is what powers the admin interface and is consumed by all the job pages too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data
&lt;/h2&gt;

&lt;p&gt;Firebase is where all of my data lives. I use Firestore via the Firebase Admin SDK. I don’t use Firestore in the traditional way from the front end, it’s all handled from the server. Firebase has been a really great choice for the database as it’s quick and cheap to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication
&lt;/h2&gt;

&lt;p&gt;When picking an auth provider I wanted a turnkey solution. There are a lot of moving parts, from account creation to password resets.&lt;/p&gt;

&lt;p&gt;As I am already using Firebase for my data and meets all my requirements, it handles my auth too. It is a really great tool that supports social login from the likes of Google, Apple or Twitter and requires very little code to get started. I have intentionally not provided a login method that requires a password as that would be more for me to maintain. Instead, users can log in with a social provider, or by using their email to get a magic login link.&lt;/p&gt;

&lt;h2&gt;
  
  
  Payments
&lt;/h2&gt;

&lt;p&gt;You’ll not be surprised to hear that my payments are handled by Stripe. I use Stripe Checkout. This is a prebuilt UI for taking card payments. When a user is ready to pay, I redirect them to a checkout page on Stripe where the transaction is handled. This way, a user never enters payment details on my site. Ensuring a website meets the legal requirements to process payments is hard, so I’ve left that liability in Stripe’s capable hands. When Stripe successfully charges the user, they send me a webhook and the user’s draft job goes live.&lt;/p&gt;

&lt;h2&gt;
  
  
  Regrets
&lt;/h2&gt;

&lt;p&gt;While I love all the tools I’ve used for building &lt;a href="https://wecoderemote.com"&gt;weCode Remote&lt;/a&gt; and &lt;a href="https://wecodeni.com"&gt;WeCode NI&lt;/a&gt;, there are some things that aren’t perfect. For me, the biggest pain point when working on these projects always come from Firebase. The client side auth library is 54kB gzipped, which is a lot of code for the relatively few users who need it. If I was to start over, I’d probably use Auth0.&lt;/p&gt;

&lt;p&gt;Firestore is the other part of this tech stack that I would swap out of starting over. It is a noSQL type database which charges you per document read. This means pulling together reports based on the data can be expensive. It’s also difficult to export data from Firestore. I would like to move to a Postgres database sitting behind Prisma. I’d looked into this when I was first getting started, but Prisma was still in beta and the API was changing too regularly.&lt;/p&gt;

&lt;p&gt;What do you think? What tools would you use to build a job board like this?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>saas</category>
    </item>
    <item>
      <title>A Short Horror Story</title>
      <dc:creator>Paul McBride</dc:creator>
      <pubDate>Wed, 05 Jun 2019 16:54:25 +0000</pubDate>
      <link>https://forem.com/thepaulmcbride/a-short-horror-story-3af8</link>
      <guid>https://forem.com/thepaulmcbride/a-short-horror-story-3af8</guid>
      <description>&lt;p&gt;Everyone that works in tech has a horror story or two. Making mistakes and doing stupid things is all part of being human. With that in mind, let me tell you about something dumb I did recently!&lt;/p&gt;

&lt;p&gt;On Monday, when I got into work, I took my laptop out of my backpack, placed it on my desk and at the same time, opened the lid and plugged in an external display. This is where things started to go wrong.&lt;/p&gt;

&lt;p&gt;When I plug a display into my laptop, both screens go blank for a few seconds. This is perfectly normal as the laptop tries to work out the best resolution to display everything at.&lt;/p&gt;

&lt;p&gt;Now, on Monday, I had a busy morning planned so to save a tiny bit of time, while the screens were still blank, I typed in my password and hit return. Unfortunately, while the screens were blank, my laptop had detected that I was wearing my Apple Watch, automatically unlocked and re-opened Slack.&lt;/p&gt;

&lt;p&gt;I had just typed my password into Slack and sent it into a channel with of 2000 members.&lt;/p&gt;

&lt;p&gt;Yikes!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkmrgicbaizg43arqd99d.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkmrgicbaizg43arqd99d.gif" alt="Grimacing Face"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you any short horror stories like this? I'd love to hear them!&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Don't Trust the Cascade - Why I write CSS in JavaScript</title>
      <dc:creator>Paul McBride</dc:creator>
      <pubDate>Sat, 01 Jun 2019 17:08:01 +0000</pubDate>
      <link>https://forem.com/thepaulmcbride/don-t-trust-the-cascade-why-i-write-css-in-javascript-408k</link>
      <guid>https://forem.com/thepaulmcbride/don-t-trust-the-cascade-why-i-write-css-in-javascript-408k</guid>
      <description>&lt;p&gt;If you've been on the internet recently, you've probably heard of CSS-in-JS.&lt;/p&gt;

&lt;p&gt;The technology has been growing in popularity recently but not everyone is a fan. Today, I'd like to demystify what it is and why I think you should be using it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BmyTIymZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0u75y75y7l7zme2wywi4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BmyTIymZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/0u75y75y7l7zme2wywi4.png" alt="A tweet that explains the C in CSS stands for JavaScript"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CSS-in-JS can mean a few things, but primarily it is used to describe the technique of authoring styling logic in JavaScript. This can be done in the form of &lt;a href="https://reactjs.org/docs/dom-elements.html#style"&gt;inline styles attached to a react component&lt;/a&gt; or by leveraging a tool like &lt;a href="https://www.styled-components.com/"&gt;Styled Components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, if you're anything like me, when you first heard the term CSS-in-JS you probably thought:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Oh no... not another thing I have to learn!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I have good news though if you already know CSS, you don't really have to learn anything new. But wait, if you already know CSS, then why bother writing CSS-in-JS, doesn't that just add complexity?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Write CSS-in-JS 🎨
&lt;/h2&gt;

&lt;p&gt;CSS stands for Cascading Style Sheets. Back when CSS was created, we were building websites which were typically pretty simple by today's standards. At the time, the &lt;em&gt;cascading&lt;/em&gt; part of CSS was super useful. Today, however, I think it ends up being a foot-gun more often that it is helpful. Think about it, can you remember every class name you used on your last project?&lt;/p&gt;

&lt;p&gt;Now imagine working on a project with several other people. Writing CSS that conflicts with or overwrites someone else's styles is essentially inevitable. Techniques like BEM and SMCSS can help but you have to rely on all developers following the rules and as a project grows so do the chances that someone will slip up.&lt;/p&gt;

&lt;p&gt;For me, CSS-in-JS and Styled Components in particular help save me from myself. I'm protected from my own mistakes by an API instead of by convention. CSS-in-JS allows me to focus on styling my UI without having to be mindful of overwriting CSS somewhere else.&lt;/p&gt;

&lt;p&gt;The cascade can still be useful, however. With Styled Components, you can still take advantage of the cascade but it is limited to the scope of the component you're working on. You &lt;strong&gt;can&lt;/strong&gt; have your cake and eat it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance 🚀
&lt;/h3&gt;

&lt;p&gt;Okay, let's say you never make mistakes. Are there any benefits to CSS-in-JS besides controlling the cascade. As it turns out, there are. CSS-in-JS libraries are responsible for how styles are injected into the DOM. They can track which components are rendered and only inject the styles required.&lt;/p&gt;

&lt;p&gt;This means the user ends up downloading fewer bytes of code and will have a quicker time to first paint. Great success.&lt;/p&gt;

&lt;h3&gt;
  
  
  Maintenance 🔧
&lt;/h3&gt;

&lt;p&gt;Have you ever wanted to remove some CSS from a project but you had no way to be sure it wasn't being used somewhere. With CSS-in-JS, this usually isn't a problem as styles are typically co-located with the component that relies on them. You'll never have to go hunting for the CSS that is affecting the component your working on again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic Styles
&lt;/h3&gt;

&lt;p&gt;Another benefit of using CSS-in-JS is that you can take advantage of the power of JavaScript. You can use functions to create mixins and reusable style modules, props can be used to create variations of components and variables can be used for theming.&lt;/p&gt;

&lt;p&gt;Most CSS-in-JS tools give you all the benefits of traditional CSS preprocessors too, including nested rules and auto-vendor prefixing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the disadvantages of CSS-in-JS
&lt;/h2&gt;

&lt;p&gt;All tech choices involve some sort of compromise and using CSS-in-JS is no different. The primary drawback of using something like Styled Components is the added complexity. First of all, it needs to be installed from npm. Not a big deal, but it is one extra step.&lt;/p&gt;

&lt;p&gt;If you are sever rendering your code, you're going to need to install and configure a babel plugin to make sure your styles work on the first load too.&lt;/p&gt;

&lt;p&gt;The other drawback of CSS-in-JS is that it just might not work for your particular application. If you're not using a front end framework like React or Vue, CSS-in-JS is probably not the right choice.&lt;/p&gt;

&lt;p&gt;If you're in a situation where CSS-in-JS isn't a great fit, I highly recommend you check out &lt;a href="https://tailwindcss.com/docs/what-is-tailwind/"&gt;Tailwind CSS&lt;/a&gt;. It is a utility first CSS framework that helps you build UI's rapidly. You don't get any of the benefits of CSS-in-JS but it may help you avoid some of the pitfalls of CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thoughts
&lt;/h2&gt;

&lt;p&gt;As developers, our job is to solve problems using code. CSS-in-JS is a tool that helps us solve problems more efficiently and write code that should be easier to maintain.&lt;/p&gt;

&lt;p&gt;If you've tried a CSS-in-JS solution and it didn't work out, that's cool too. Do what works best for you and your team.&lt;/p&gt;

&lt;p&gt;Let me know if you have used CSS-in-JS and what problems it solved/caused for you!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
