0

So i want to make a button for my website where whenever someone clicks it, it adds to a click counter that everyone can see. so basically everyone can work together to click a button. im using github for my website, so would this be possible since its static?

Tom Moore
  • 11
  • 2
  • 2
    This is likely a duplicate of [Deploying react app on github pages front and backend in the same repository](https://stackoverflow.com/questions/52969697/deploying-react-app-on-github-pages-front-and-backend-in-the-same-repository), unless somebody else can come along and show contrary. – Alexander Nied May 16 '22 at 15:53
  • Have you considered learning React hooks? You can use a method called useState that will consistently update a counter everytime a button is clicked... https://reactjs.org/docs/hooks-state.html – SupraCoder May 16 '22 at 15:53
  • 1
    @SupraCoder -- the feature the user is asking for is for several different visitors to all update the _same_ counter. Furthermore, this question doesn't specify that the page is built with React. – Alexander Nied May 16 '22 at 15:54
  • github pages doesnt support serverside code is the problem, only static files, so how would i do this? – Tom Moore May 16 '22 at 16:43
  • It's basically impossible without some form of server side code. Even if you could figure out a way to do some [wild direct peer-to-peer communication without a server](https://stackoverflow.com/questions/7022383/how-can-i-make-a-browser-to-browser-peer-to-peer-connection) (which I suspect is impossible for your use case), there'd be no way to reliably retain the count as people closed their browsers. – Alexander Nied May 16 '22 at 19:37

0 Answers0