How to implement decoupled user registration with React / jsonapi? I have built a React app that uses JSON:API to pull in data, but now I want to implement user registration.
JSON:API doesn't do user registration because it isn't a CRUD operation.
However, the links above explain that core provides a REST endpoint for handling user registration.
The documentation gives this example:
curl \
  --header &quot;Content-type: application/json&quot; \
  --request POST http://drupal.d8/user/register

But this example seems incomplete-- for example, where is the username?
My website is configured with the Email Registration module and only an email address is required to register, but where do I submit the email address?
EDIT: If you're answering this question, I will accept an answer that uses core's username/email address combo for registration; it doesn't have to be specific to the Email Registration module.  The problem is that I can't find an example of how to register users with JSON:API, and there is no documentation.
Here's the code I tried in React:
UserRegistrationForm.tsx
import * as React from 'react';
import { useForm } from 'react-hook-form';
import { IonButton } from '@ionic/react';
import { baseUrl, basicHeaders } from '../utils/globals';
import handleErrors from '../utils/fetchHandleErrors';

interface InterfaceRegistrationFormInput {
  email: string;
}

const UserRegistrationForm: React.VFC = () =&gt; {
  const { register, handleSubmit, errors } = useForm&lt;InterfaceRegistrationFormInput&gt;();

  const onSubmit = (formData: InterfaceRegistrationFormInput) =&gt; {
    fetch(`${baseUrl}/user/register`, {
      method: 'POST',
      headers: basicHeaders,
      body: formData,
    })
      .then(handleErrors)
      .catch((error) =&gt; Promise.reject(new Error(error)));
  };

  return (
    &lt;&gt;
      &lt;form onSubmit={handleSubmit(onSubmit)}&gt;
        &lt;label htmlFor=&quot;email&quot;&gt;
          Email address
          &lt;br /&gt;
          &lt;input
            name=&quot;email&quot;
            type=&quot;email&quot;
            ref={register({ required: true })}
          /&gt;
        &lt;/label&gt;
        &lt;IonButton type=&quot;submit&quot;&gt;Register&lt;/IonButton&gt;
      &lt;/form&gt;
    &lt;/&gt;
  );
};
To register user using core Rest Module you need 5 steps:
Step 1: Download and enable Rest UI module, this module provides a user interface for administrating Rest Endpoints. Using this module's configuration (admin/config/services/rest) Enable User Registration

Step 2: Then in account setting configuration you should allow user to create account, and if you want user to be added using user name and password you will need to uncheck require email verification else leave it checked.

Step 3: Now you need to allow anonymous user to access user registration (admin/people/permissions/anonymous):

Step 4: Another step to take is to get a xcsrf token from drupal cause you need to use a post method for user creation and post methods are unsafe methods, so drupal protects them using token, to get a XCSRF Token simply call /session/token endpoint.
Step 5: Now final step is to ask for user creation:
Method: POST
Endpoint: user/register?_format=json
Header:
Content-Type: application/json
Accept: application/json
X-CSRF-Token: &quot;XCSRF TOKEN PROVIDED BY DRUPAL&quot;

Body:
{
  &quot;name&quot;: [{&quot;value&quot;: &quot;USERNAME&quot;}],
  &quot;mail&quot;: [{&quot;value&quot;: &quot;EMAIL&quot;}],
  &quot;pass&quot;:[{&quot;value&quot;: &quot;PASSWORD&quot;}]
}

and that's it.
PS:
Remember that if you have not unchecked &quot;require email verification&quot; in account settings form then you should exclude pass from your request body. in this case user needs to navigate to your drupal site for email verification which in case of decoupled scenario it sounds wired. so I highly recommend to uncheck this option in account settings configuration.
Another PS:
If you need to require user to confirm his/her email, then you can use a simple solution, like add a verify code to user (prevent user access to this field using Field Permissions module) then in hook_user_presave you can assign a code to it, send user an email containing this code and finally deactivate user) , finally you will need a custom Rest endpoint so user can fill a form containing email field and code and if code matches the one you sent you can activate user's account.