DEV Community

Chris Connelly
Chris Connelly

Posted on

1 3

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

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay