Ask coding questions

← Back to all posts
Reactjs replit auth
darkdarcool (132)

Hi!

I was trying out react.js, and wanted to start with a simple
Hello {username} with a replit auth. But I couldn't figure out how!

Can someone give me a repl(forked would be nice) of this? And if the auth is successful to redirect to another page?(Just give me the <Link to="/home"> and I will wire it in.

Thanks!!(Please not express, reactjs)

Answered by Coder100 (18123) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18123)

you can't, you have to use something like express or https://nextjs.org to get the headers

darkdarcool (132)

@Coder100
oh, well that sucks. Maybe I'll try to do something else

darkdarcool (132)

@Coder100
can you give me an example to get it in nextjs?

darkdarcool (132)

@Coder100
Yes!!! But instead of a new component showing up, can we gat a page redirect?

darkdarcool (132)

@Coder100
so would I do like a location.replace("/home") which is a link to home.js. And would the headers be there for that page?

darkdarcool (132)

@Coder100
can you edit the page(repl) above so I can see if I wanna do that?

Coder100 (18123)

maybe check out docs too next time @darkdarcool

darkdarcool (132)

@Coder100
nice! Thanks a lot, it looks really good, so In any code I just do {authed} and it will display the username? nice!