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

208
Views
Gatsby.js adding a global function to checkUserSession

I am wondering how to set a global function to be rendered in all gatsby pages, by using create-react-app I used to do that in the App.js file,but now I don't know how to manipulate it with using Gatsby this is what I want to implement :

const dispatch = useDispatch()
useEffect(()=>{
  dispatch(checkUserSession())
}, [])
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You can use one of the multiple Gatsby Browser APIs. In your case, onRouteUpdate should do the trick. Add in the gatsby-browser.js the following:

exports.onRouteUpdate = () => {
  checkUserSession()
}

onRouteUpdate is called when the user changes routes, including on the initial load of the app

about 4 years ago · Santiago Gelvez 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!