gitntg/pshophydrauth icon
public
Published on 3/30/2025
Shopify Hydrogen Authentication

OAuth Authentication setup according to hydrogen/shopify standards - sets up basic components for the authentication if needed - uses currently standing components if not

Prompts
Authentication
Implement Shopify customer authentication in Hydrogen.
Set up Shopify OAuth authentication in Hydrogen for secure customer logins.

- Check if Shopify provides built-in authentication components and use them if available.
- If authentication components are not provided, set up basic login UI (email/password input, OAuth login button).
- Use Shopifys `customerAccessTokenCreate` mutation to handle authentication.
- Store the access token securely (e.g., session storage, HTTP-only cookies).
- Implement a logout function using `customerAccessTokenDelete`.
- Set up authentication context or state management to persist user session.
- Ensure authenticated routes restrict access to logged-in users.
- Handle error states (e.g., invalid login, expired tokens) with proper UI feedback.