Using .ENV to Hide Your Air Table Credentials In React

teamallnighter

Chris Connelly

Posted on September 3, 2020

Using .ENV to Hide Your Air Table Credentials In React

Create a dotenv file

First you'll want to create a .env file

AIRTABLE_API_KEY=xxxxxxxxxx
AIRTABLE_BASE_ID=appxxxxxx
AIRTABLE_TABLE_NAME=base-1
Enter fullscreen mode Exit fullscreen mode

Install dotenv

Once you have this created you can use it by installing dotenv

npm -i dotenv
Enter fullscreen mode Exit fullscreen mode

Set up dotenv in airtable.js

require('dotenv').config();
var Airtable = require('airtable');
var base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY }).base(
    process.env.AIRTABLE_BASE_ID
);
const table = base(process.env.AIRTABLE_TABLE_NAME);

module.exports = { table };
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
teamallnighter
Chris Connelly

Posted on September 3, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related