+
Profile Data
+
+ {JSON.stringify(loaderData, null, 2)}
+
+
+ )
+}
+```
+
+### Server action
+
+Unlike the previous example that loads data when the page loads, the following example uses `getAuth()` to only fetch user data after submitting the form. The helper runs on form submission, authenticates the user, and processes the form data.
+
+```tsx {{ filename: 'app/routes/profile-form.tsx' }}
+import { redirect, Form } from 'react-router'
+import { getAuth } from '@clerk/react-router/ssr.server'
+import { createClerkClient } from '@clerk/react-router/api.server'
+import type { Route } from './+types/profile-form'
+
+export async function action(args: Route.ActionArgs) {
+ const { userId } = await getAuth(args)
+
+ if (!userId) {
+ return redirect('/sign-in?redirect_url=' + args.request.url)
+ }
+
+ const formData = await args.request.formData()
+ const name = formData.get('name')?.toString()
+
+ const user = await createClerkClient({
+ secretKey: process.env.CLERK_SECRET_KEY,
+ }).users.getUser(userId)
+
+ return {
+ name,
+ user: JSON.stringify(user),
+ }
+}
+
+export default function ProfileForm({ actionData }: Route.ComponentProps) {
+ return (
+