Skip to content
Ryan James
Menu

← Blog10 min read

Learning a New Stack

I've been dabbling in web development off and on for the past 3-5 years. I started off with HTML and CSS and using tools like GitHub Pages to serve the static content. Once I got more comfortable with OOP in Python, I learned how to build applications with a server using Python and SQL as my backend serving template pages. This was hard to keep track of sessions and creating a complex schema with relations, but it worked. Now I'm on a new iteration of building for the web. I drank the Kool-Aid and I'm doing Jamstack for a while now. I had to really buckle down and get back to the basics of JavaScript which is something I needed to do for a while. I'm not an expert on Jamstack or even the tools I'm using, but I'm having so much fun learning a new stack and playing with new tools. I've been quiet on the programming front for the past 2 years, but this has really invigorated me to get back to it. Let's dive in to this and see what you can do with this.

Learning a New Stack

Little Late, but Much Love for Jamstack

I’ve been dabbling in web development off and on for the past 3-5 years. I started off with HTML and CSS and using tools like GitHub Pages to serve the static content. Once I got more comfortable with OOP in Python, I learned how to build applications with a server using Python and SQL as my backend serving template pages. This was hard to keep track of sessions and creating a complex schema with relations, but it worked. Now I’m on a new iteration of building for the web. I drank the Kool-Aid and I’m doing Jamstack for a while now. I had to really buckle down and get back to the basics of JavaScript which is something I needed to do for a while. I’m not an expert on Jamstack or even the tools I’m using, but I’m having so much fun learning a new stack and playing with new tools. I’ve been quiet on the programming front for the past 2 years, but this has really invigorated me to get back to it. Let’s dive in to this and see what you can do with this.

Jamstack or JAMstack…What Is This

Alright, so Jamstack also uses the spelling with JAMstack…they’re the same. The acronym comes from JavaScript, API, and Markup, which is not required to be used for an app to be part of the Jamstack. The Jamstack today really refers to a webapp built with serverless tools. When I first started getting into building my sites, it boggled my mind how you can build a serverless app that is serving up data dynamically. I remember playing around with React before I tried out the Gatsby JS framework. Gatsby is really fun and this site as of the publishing of this post runs on Gatsby. You create your API so that when a new post, in this case a new markup file gets uploaded, the site gets rebuilt with a webhook from Netlify. What’s happening is there is a static build of the site when this change happens and that’s what’s getting rendered.

Now, what tools do I use now? I’m currently writing my websites using Next JS. I made the switch to Next from Gatsby after trying out Next JS. The routing of the url slugs and some of the built in functionality like image optimization really made me more comfortable using Next. Now that I’ve gotten used to using it, setting up my data outside of the website and doing queries makes sense to me. There are a lot of frameworks out there and you really have to find what you like about each to start using them. Next is built by Vercel and they also provide hosting for your Next app similar to Netlify (not the same though). In addition to using Next for my framework, I’m using GraphCMS for my backend. I like Hasura a lot, but since I’m dealing with mainly blog content at this point, GraphCMS is a great way for people who aren’t too tech savvy to update the content. I’m only keeping content in there, no authorizations or anything is being done through my CMS. For frontend, I’ve picked up Tailwind CSS. I usually have trouble making things look good, but Tailwind has really helped me start styling the UI better by writing minimal CSS.

The Walk Through

Ok, so let’s go through the workflow of building a website using Next JS, Tailwind CSS, and Graph CMS. This is going to be very sparse and big picture thinking. But, you should be able to get an idea of the processes that go into building this site. My profile site (repo here) gives you an idea of what you can do from this process.

If you want to try to replicate everything I did, you’ll need accounts on GitHub, Vercel, and on GraphCMS. You can start by ensuring you have accounts for all of those sites. The next step is to create your next-app with Next JS. You can read how to do this in the Next documentation. Once that is done, what you’ll want to do is install your libraries with either npm or yarn. The command line instructions look like this:

    npx create-next-app your-project-name-goes-here --use-npm
    npm install -D tailwindcss
    npx tailwindcss init
    npm install graphql-request

Once you have it set up, then you can start creating your project. Using npm run dev on your command line will start your website on your localhost. You’ll want to add in your HTML code on the index.js page. If this is the first time you’ve done anything in React, I would suggest the Traversy Media video on Next. It’s lengthy and may feel like drinking from the fire hose, but it’s worth the time. For my site I created components for the layout, header, and footer. In the _app.js I wrapped the props with the layout and used the header and footer in the layout. By passing the children through the layout, any content I add to the index.js page will be rendered in this layout. If I made a multi-page site, only the new content would be rendered in each page resulting in really quick load times.

I don’t want to go in to how I used Tailwind, save that for another post. But, if you look at the code in my repo, you can see what classes I used from the Tailwind library. Almost all of the CSS that I used for this project came from Tailwind. You can just use the classes in your components and pages and not have to worry too much about the CSS.

This page is a single page and I could have just left all the content as static. The result of that would mean I would need to change the code, commit my changes, and push to GitHub. This isn’t that big of a deal if you’re comfortable with those tools, but it’s much easier to use a content management system. All of the hyperlinks, pictures, and content live on GraphCMS. I can go into my account on GraphCMS and make changes to the content. When I publish those changes, it triggers a webhook from Vercel which rebuilds the static site using the SSG and voila - new content is live!

But Where Is the Code?

Ok, so this website uses serverless functions. But that doesn’t mean the code doesn’t live somewhere. The way that it’s done is I created a repo on GitHub where I can upload all of the pages, routing, and API scripts. Then with Vercel, I can create a Vercel project that is built from the repo. Anytime there is a change in the repo, the Vercel project is rebuilt automatically. You don’t have to create a webhook for this to happen - it’s done for you.

I’ve been having a lot more fun lately diving into web dev again and hope to keep it up. I plan on rebuilding this site using what I went through in this and adding authorization so that some of the content is available to specific people. If you’re building something new, I’d love to hear about it. Shoot me a message or tweet and I’d love to talk with you about your next project.

Keep coding!
Ryan