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

203
Views
Pass variable from express server to react application

So I am using react universally and I want to pass some variable value to the react application from the server without having to do an ajax request after it's loaded. The react application is loaded like:

const someVariable = 'some variable';
// The React application middleware.
app.get('*', reactApplication);

How can I pass it to down so that it will be available in the react application?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can add a header property in express/node-server:

res.writeHead(statusCode , {header properties})    
(fast, not cached by default)

-or-

Parse your index file and inject your property right into the head (not fast, can be cached to be faster) and check for that property in react with

document.getElementById('propertyId')

-or-

document.getElementByTagName('propertyTag')
about 4 years ago · Santiago Trujillo Report
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!