Get in touch

Copy to clipboard

Simple function to copy text to the user's clipboard

ts snippet

CSS Gradient text

Add A Linear gradient to your text

css snippet

Download object as JSON file

Programmatically convert a JS object into a downloadable JSON file

ts snippet

Randomise array

A simple method for randomising the contents inside a given array.

ts snippet

React debounce hook

A simple React TS hook for debouncing requests

react ts snippet

Reset all Git history

Reset all Git history and set a new commit as the first commit

git learn

Copy to clipboard

Simple function to copy text to the user's clipboard

Accessing the clipboard API can fail if the user hasn't set the correct permissions in there browser or if your site is not secure. Using a try/ catch block lets us handle any errors gracefully.

async function copyStringToClipboard(string: string): Promise<void>  {
  try {
    await navigator.clipboard.writeText(string);
  } catch (err) {
    console.error("Failed to copy text: ", err);
  }
};

copyStringToClipboard(myString);

Get in touch

Whether you want to connect, collaborate, or just say hello, feel free to reach out 😊

Avatar of Brad Coulson