Skip to main content
The /register route handles new user registration. A GET request renders the registration form; a POST request creates a Stripe customer and redirects the user to the pricing page.

GET /register

Renders the registration form, which collects the user’s email address and name.

POST /register

Processes the registration form, creates a Stripe customer, persists the customer ID in the session cookie, and redirects to /prices.

Request

Content-Type: multipart/form-data
email
string
required
The user’s email address. Passed directly to createCustomer when creating the Stripe customer record.
name
string
The user’s display name. Passed to createCustomer alongside the email address.

Action source

export const action = async ({ request }: ActionFunctionArgs) => {
  const data = await request.formData();
  const email = data.get("email") as string;
  const name = data.get("name") as string;
  const createdCustomer = await createCustomer(email, name);

  const session = await getSession(request.headers.get("Cookie"));
  session.set("customerId", createdCustomer.id);
  return redirect("/prices", {
    headers: { "Set-Cookie": await commitSession(session) },
  });
};

Side effects

  1. Calls createCustomer(email, name) to create a new customer object in Stripe.
  2. Writes the returned customer.id into the session under the key customerId.
  3. Commits the updated session and sets it as a Set-Cookie response header.

Response

StatusDescription
302Redirects to /prices. The Set-Cookie header carries the newly committed session containing the Stripe customerId.
The customerId stored in the session is required by the /prices route to create a subscription. Without a valid session, subsequent requests will fail to retrieve a customer ID.
The email field is required. If it is missing or empty, createCustomer will receive an empty string and Stripe will return a validation error.

Build docs developers (and LLMs) love