Ask coding questions

← Back to all posts
Is there any way to authenticate users in React?
MatthewDoan1 (325)

Basically the title. I see auth being used mainly on the server-side, but is there any way to use it on the client-side with ReactJS?

ironblockhd (345)

It is possible with fetch and localStorage, here's an example in express:

MatthewDoan1 (325)

@ironblockhd Ah, beautiful example. Thank you so much!

Coder100 (6992)

hmm you still need a backend @ironblockhd

ironblockhd (345)

I think he has a express backend so it's working for this specific question, i agree that the name of my repl is chosen poorly

MatthewDoan1 (325)

@ironblockhd Hm, it doesn't work inside a React component.

ironblockhd (345)

I modified my repl in a way it should work with react, you will need to change the buttonn as specified here:

PattanAhmed (1014)

@MatthewDoan1 Hi,
You will also need Front-End and Back-End


React.js is just Front-End and you need Back-End like HTML, Python, etc.

Hope this helps
Please mark my answer if this helps

Coder100 (6992)

sorry, that is not possible, you will need a backend to parse the header.

MatthewDoan1 (325)

@Coder100 Yea, I'm using an Express backend right now, just for an API to connect to a database (Firestore). I don't want to go through all the redirects and stuff because my app is an SPA. is this still possible?