https://supertokens.com/ logo
#community
Title
# community
i

ITEnthusiasm

06/13/2022, 4:28 PM
Okay. I've been working on this for awhile. It still is not finished, and it can probably be improved upon. But here's my running example of using
Remix
with `SuperTokens`: https://github.com/ITenthusiasm/remix-supertokens Does SuperTokens ever review this kind of stuff? If it's written correctly, it should enable people to get auth up and running without end users needing to enable JavaScript. It might also give new ideas for the default forms exported by SuperTokens. If it's written incorrectly or I'm missing any use cases / error cases (specifically within login/signup/resetting passwords), I can try to fix those. 🙂 The 2 things I hope to add in the future are specified in the TODO list. (They are JS-enhanced forms and a local db example... if I find time.)
I should probably update the README so people know how to run the app. 🤔 I use SCSS so people will have to build the CSS. Very easy though.
r

rp

06/13/2022, 4:29 PM
oh! real cool!
will check it out! really curious to know how you are managing sessions without JS enabled on the frontend
i

ITEnthusiasm

06/13/2022, 4:31 PM
I could be doing it wrong entirely! That's why I want someone to review it. 😂
I just noticed that login/logout etc. is working fine.
r

rp

06/13/2022, 4:31 PM
haha well.. have you tried to get session refreshing to work? That definitely requires JS
i

ITEnthusiasm

06/13/2022, 4:34 PM
Don't think so. I just wanted to get the basics down with logins/logouts/resets. If
supertokens-website
handles the session refreshing for us, then it shouldn't be too hard to add that into the app.
r

rp

06/13/2022, 4:34 PM
yup!
Or else, if you don't care about things like session refreshing, you could customise the backend to just issue a long lived token as cookie. And then you don't need supertokens-website at all.
i

ITEnthusiasm

06/13/2022, 4:35 PM
The app isn't "progressively enhanced" yet. I still need to add the ability for error states to disappear after interaction and a couple other things. Trying to figure out the cleanest way to bring in JS and still have it work for people without JS.
Oh nice!
i

ITEnthusiasm

06/13/2022, 4:41 PM
Sweet. I'll check this out when I get the chance.
Any chance someone got to look at the code? If not that's okay. I'm mainly wanting to make sure that at least the authentication piece is valid before continuing forward with the example. I intend to handle the refresh later. Though again, hooking up
supertokens-website
should be pretty easy to do from the client-side
root
file.
r

rp

06/28/2022, 4:03 AM
Hey @ITEnthusiasm will have a look sometime this week
i

ITEnthusiasm

07/01/2022, 9:45 PM
Sounds good! I added a tiny bit of client-side validation while waiting.
r

rp

07/02/2022, 4:53 AM
hey @ITEnthusiasm i opened 2 issues in the repo. Also, could you explain how the APIs exposed by the SuperTokens middleware are being called?
For example, i see that the login form submits the data to the
/login
server route, but then how does that leverage the API route for login exposed by the supertokens' middleware?
i

ITEnthusiasm

07/02/2022, 2:07 PM
Thank you! I responded to the build problem GH Issue. I'll try to look at the second one soon (hopefully later today).
r

rp

07/02/2022, 2:07 PM
cool!
i

ITEnthusiasm

07/02/2022, 2:07 PM
Yeah so the SuperTokens auth routes are handled by Remix's backend. The
action
functions in Remix routes are responsible for handling form submissions. So if you look at the
action
function inside the
login.tsx
route, you'll see that I'm grabbing the login data and then sending it to the SuperTokens route in a way that it can understand. Since the SuperTokens routes exist on the same server, this results in the server making a request to itself. This is necessary in order to guarantee that I can leverage how Remix handles forms (and to guarantee that people can login without JS). However, from what I understand, when Remix sees that the server is making a request to itself, it will instead invoke the appropriate middleware without making any HTTP requests (thankfully).
r

rp

07/02/2022, 2:11 PM
understood! this makes sense. I'll have a look at this app once again
i

ITEnthusiasm

07/02/2022, 5:15 PM
Thanks!
3 Views