DEV Community

Cover image for Exploit Airtable inside your React app
Nans Dumortier
Nans Dumortier

Posted on • Originally published at

Exploit Airtable inside your React app

Cover photo by Jan Antonin Kolar on Unsplash


At Karbon 🌱, we iterate fast and we are always looking for ways to improve our products and services.

We had the idea of building an idea box, allowing users to create, share and vote for ideas of new features.

This is the typical project where we have to store unsensitive data entered by users. However we wanted to avoid impacting the rest of our application (e.g we don't want to change our database schema).

Airtable is a great tool for this kind of usecase.

Let's build this idea box ! 🗳️

Airtable provides an npm package to interact with their API.
However, since I was working with multiple tables (one for votes, another one for ideas), I found myself repeating a lot of boilerplate code.
I landed on a hook that seemed to provide a nice abstraction to interact with Airtable, but it had some bugs and the author didn't seem to willing to spend time on it. So I decided to write my own hook.

On top of fixing a few issues, I worked on the following points :

  • provide an option to handle errors when fetching, updating or deleting data
  • provide an option to filter records using Airtable's QueryParams

Usage 👩‍💻👨‍💻

Install the hook and Airtable's package with your favorite package manager, for example npm :

npm install --save airtable use-airtable-crud
Enter fullscreen mode Exit fullscreen mode
const { records, createRecord, updateRecord, deleteRecord, getRecords, loading } = useAirtable(
      filterByFormula: '{myField} = TRUE()',
Enter fullscreen mode Exit fullscreen mode

You can find the source code of the hook here.


I hope this hook can be useful for you too! Prototyping and iterating is a great way to learn new things.

Top comments (0)