Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Access .env variables in js file Laravel. Not in blade file

I've set the following keys in my .env file.

AGOLIA_APP_KEY="appKey"
AGOLIA_APP_SECRET="appSecret"
AGOLIA_APP_INDEX="appIndex"

I want to access these variables in my script file agolia.js as the following.

    let client = algoliasearch(
        process.env.AGOLIA_APP_KEY,
        process.env.AGOLIA_APP_SECRET
    );
    let index = client.initIndex(process.env.AGOLIA_APP_INDEX);

With the above config. Laravel mix compiles the file with success but instead of variables same string text are seen in compiled file.

I.E: process.env.AGOLIA_APP_KEY

How can I access .env variables in javascript files ? Most of the answers were about accessing in

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!