User signup/login with Frontity?

Hi all,
I’m looking into solutions for a React-powered frontend for a SaaS application, using WordPress as a backend (since I have other parts of the applications already hosted in a WordPress installation). One requirement is that I need to be able to create user accounts (or possibly allow people to create user accounts) in the application. It seems like a simple question, but I wasn’t able to find anything about this in the Frontity docs.
So my question is, is there some library or existing implementation for user accounts and user/browser authentication, preferably that uses WordPress? I’m not talking about REST API authentication.

Hi @scarabcoder,

As far as I know the REST API is the only endpoint that can be used for this purpose.
Or you install another Plugin to create an API on top of WordPress to be able to use the Users from WordPress.

A Topic that could help you with this is here: JWT with Frontity

Kind regards
Chris

1 Like

I’ve just been working on this for signing a user into a third party (like google) and then creating them a user account in WordPress based off of their successful google login. I then set a cookie for their JWT for both WordPress and google, then refresh them when needed.

This took me a little while to sort, but it works pretty well. Here are two plugins that were essential to getting this done:


These together let me achieve my goal. Good luck :slight_smile:

1 Like

Thanks, that’s helpful. Which library would I use for setting and retrieving those cookies?

I used this package: https://www.npmjs.com/package/react-cookie

What action would be best to set the cookie in? Got any examples?

I used a form onSubmit for mine, to set the cookie for example:

const formSubmit = () => {
    // Get a JWT, return from WordPress, if there is one, then set it to a cookie
    setCookie('jwtcookie', json.token, { path: '/' });
}
1 Like

Okay, so you did do the authentication JWT request on the frontend then? I guess that makes sense, instead of routing it through the Node server.

Yes, straight on the frontend, just chucked up a loading icon while it was “logging in…”