Quick Tips

Handy bite-sized articles on all things web-design and development. They won’t take long to read, but these tips can take you a long way! More coming soon…
How to run Typescript scripts in your Next.js project thumbnail
Leonardo Petrucci
March 4, 2023

How to run Typescript scripts in your Next.js project

If you've ever tried to add Typescript script to one of your Node.js projects to run it on its own from the command line, it's very likely you came across one of these messages: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. A quick search on Google doesn't help much. The solutions range from trying a variety of different tsconfig.json configurations and even adding "type": "module" to your

Creating a local backup of a Supabase database thumbnail
Leonardo Petrucci
October 1, 2021

Creating a local backup of a Supabase database

Supabase is an incredible Firebase alternative as well as my favorite managed Postgres provider at the moment. It's incredibly easy to use, but without having access to the server the database is hosted on some people might find creating manual backups confusing. So here's how you can create manual backups of your Supabase database. How do I create a backup of a Supabase Database? As previously mentioned, Supabase uses PostgreSQL instances for its databases and thankfully for use Postgres also has some incredibly useful CLI tools. Th

How to use Apollo Server with Next.js thumbnail
Leonardo Petrucci
July 15, 2021

How to use Apollo Server with Next.js

While working with a Next.js API that uses Apollo GraphQL I found my queries were not completing and remained in a pending state indefinitely. Here's how to fix this annoying issue. If you're trying to implement a GraphQL API on Next.js it's likely you've settled on using Apollo GraphQL Micro as it's perfect for use on Next.js' serverless API. If after implementing Apollo you found your queries getting stuck in a pending state it's because of a lesser known Next.js setting. Go into the file where your GraphQL handler runs (for me it was pages/ap

A practical example of the React useContext hook thumbnail
Leonardo Petrucci
June 6, 2021

A practical example of the React useContext hook

The React useContext hook is an extremely useful tool that is often misused or misunderstood. This can result in components that are tricky to reuse. And that can be a real problem. So here's a quick tip on how to utilise React useContext to simplify your code and make it more reusable. It's likely that at some point in your React ap

Setting safe areas in React with CSS variables thumbnail
Leonardo Petrucci
February 21, 2021

Setting safe areas in React with CSS variables

Most apps and sites have elements or menus that overlap others and depending on the number of pages you have you might want to not set these safe areas manually. So here's a little trick to set safe areas with React. Consider this simple interface: Left - Interface without safe areas, Right - with safe areas It contains a scrollable list of cards as well as fixed menu at

How to add emojis to git commits with this handy tool thumbnail
Leonardo Petrucci
December 7, 2020

How to add emojis to git commits with this handy tool

Commit messages can easily look like a wall of text and, at a glance, can be hard to follow. Gitmoji, a style guide for adding emojis to your commit, makes this a problem of the past. Today we'll go through how to add emojis to git commits quickly and easily using this resource. If you've been maintaining a project on Github for a while, it's likely you've looked at your list of commits and been disappointed by how hard to find specific things were. And if you've be

How to: Deploy Node.js apps to Apache Ubuntu thumbnail
Leonardo Petrucci
October 1, 2020

How to: Deploy Node.js apps to Apache Ubuntu

Learning how to deploy Node.js apps on web-servers like Apache is surprisingly confusing. Here's how you can host your Node.js apps on a standard Apache server. The problem with Node.js and Apache If you've tried to run a Node.js app on a more standard web-server that uses Apache or Nginx, you may have noticed that the process of putting your app online isn't as simple as you thought. Starting the app is easy as you have access to your server's terminal, but soon you'll realise that your app is being shown on your doma

How to connect to a remote MySQL Database with SSH thumbnail
Leonardo Petrucci
April 19, 2020

How to connect to a remote MySQL Database with SSH

MySQL databases are the backbone of the internet. But developing with them can be a pain if you can't afford to run them locally. This solution allows you to connect to your remote MySQL database without any extra setup. I recently had to expand my knowledge and build my own API, rather than using a freely available one. But the hardest part wasn't making the API itself. It was connecting with my Database. But why? A default MySQL installation is likely to block any connection requests happening from outs