-
Notifications
You must be signed in to change notification settings - Fork 0
Authentication
Andreas Ekström edited this page Jul 18, 2026
·
2 revisions
ViteWP uses WordPress-native cookie authentication on the unified site origin. Login, logout, password reset, and /wp-admin/* stay WordPress-rendered by default, while Astro SSR can read the current user without manually passing cookies:
---
import { getCurrentUser, loginUrl } from 'vite-wp/wordpress';
const user = await getCurrentUser();
const signIn = await loginUrl();
---
{user ? <p>Signed in as {user.displayName}</p> : <a href={signIn}>Sign in</a>}WooCommerce account/session helpers use the same invisible request context:
---
import { getCart, getCurrentCustomer } from 'vite-wp/woocommerce';
const customer = await getCurrentCustomer();
const cart = await getCart();
---For maximum plugin/payment compatibility, /my-account, /cart, and /checkout are WordPress-owned routes by default. Override wordpress.routes.wordpress in vitewp.config.ts when you are ready to render one of those paths in Astro.