1

I am hoping to create a React Site that uses Craft CMS and the Element API as a backend. However, I know I will need to authenticate users and be posting data back into Craft which I believe the Element API doesn't support.

I was hoping someone might be able to talk me through if authenticating users is possible using a plugin and craft session service and if so what would be the general strategy given that this would be (at least in development) across two origins.

  1. stage.project.com // craft cms w/ element api
  2. localhost:3000 // react development

I haven't found any plugins out there that do just this, but it seems like it would be possible with a craft plugin. Just wanted to confirm that this is possible and get a sense of how before investing the time.

1 Answer 1

3

I created a react native app with Craft CMS (still version 2.6) as backend using the Element API. But you're right, user authentication is not supported by the Element API. However, I created my own plugin to get user authenticated. I even create user and update their details through the app.

But storing user sessions in React Native is another story. That has nothing to do with Craft or any other CMS system cause you can't get server session to React Native. You need to write your own session handler. I remember a good blog post about that topic: https://auth0.com/blog/adding-authentication-to-react-native-using-jwt/.

There also might be other solutions because this could be a little bit overkill.

Hope this helps you as a first start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.