Using .ENV to Hide Your Air Table Credentials In React
Chris Connelly
Posted on September 3, 2020
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
Install dotenv
Once you have this created you can use it by installing dotenv
npm -i dotenv
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 };
💖 💪 🙅 🚩
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.