W
Wasp•3w ago
Gus

Change LoginSignupForm

Hey there, how can I change the UI for the Login/Signup form in WASP (the built-in one) .
10 Replies
kapa.ai
kapa.ai•3w ago
Hi @Gus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
MEE6
MEE6•3w ago
Wohooo @Gus, you just became a Waspeteer level 2!
kapa.ai
kapa.ai•3w ago
---------------------- You can customize the built-in Login and Signup forms in Wasp in several ways: Basic Customization Wasp provides props you can pass to all auth forms: 1. appearance - customize colors via design tokens 2. logo - add your own logo 3. socialLayout - control layout of social buttons (vertical/horizontal) Here's an example of customizing colors:
// src/appearance.js
export const authAppearance = {
colors: {
brand: '#5969b8', // blue
brandAccent: '#de5998', // pink
submitButtonText: 'white',
},
}

// src/LoginPage.jsx
import { LoginForm } from 'wasp/client/auth'
import { authAppearance } from './appearance'

export function LoginPage() {
return (
<LoginForm
appearance={authAppearance}
/>
)
}
// src/appearance.js
export const authAppearance = {
colors: {
brand: '#5969b8', // blue
brandAccent: '#de5998', // pink
submitButtonText: 'white',
},
}

// src/LoginPage.jsx
import { LoginForm } from 'wasp/client/auth'
import { authAppearance } from './appearance'

export function LoginPage() {
return (
<LoginForm
appearance={authAppearance}
/>
)
}
Advanced Customization If you need more control, you have two options: 1. Customize the signup process: You can add extra fields or UI elements by following the instructions in the Auth Overview documentation. 2. Create your own forms: For complete control, you can build your own forms using Wasp's lower-level auth primitives:
import { login, signup } from "wasp/client/auth";
import { login, signup } from "wasp/client/auth";
You'll need to implement the userSignupFields function as described in the Auth Overview documentation. Important Note Never modify files under .wasp/out/ directory as mentioned in a Discord support thread. These are generated files and modifying them can cause problems. If you need to implement custom behavior, create new files within your src/server directory instead. Sources: Auth UI Documentation Auth Overview Documentation ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Gus, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Gus
GusOP•2w ago
@kapa.ai if I want to add translations to some elements of the login/signup forms, what would be the best way to do it?
kapa.ai
kapa.ai•2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources provided, there isn't specific documentation about adding translations to the built-in login/signup forms in Wasp. However, I can suggest a few approaches based on the customization options available: Option 1: Create Custom Forms The most flexible approach would be to create your own custom login and signup forms instead of using the built-in ones. This gives you complete control over all text elements:
import { login, signup } from "wasp/client/auth";
// Import your translation library/function
import { t } from "./translations";

// Create your own form with translated elements
function CustomSignupForm() {
// Form implementation with translated text
return (
<form onSubmit={handleSubmit}>
<h2>{t('signup.title')}</h2>
<input placeholder={t('signup.username')} />
{/* Rest of your form */}
</form>
);
}
import { login, signup } from "wasp/client/auth";
// Import your translation library/function
import { t } from "./translations";

// Create your own form with translated elements
function CustomSignupForm() {
// Form implementation with translated text
return (
<form onSubmit={handleSubmit}>
<h2>{t('signup.title')}</h2>
<input placeholder={t('signup.username')} />
{/* Rest of your form */}
</form>
);
}
As mentioned in a Discord support thread, you can import the login and signup functions from "wasp/client/auth" and build your own form while still using Wasp's authentication logic. Option 2: CSS Hacks (Not Recommended) Some users have resorted to CSS hacks to hide default elements and replace them with custom ones. As seen in a Discord thread, one user applied CSS to hide the default title:
h2 {
display: none;
}
h2 {
display: none;
}
Then they added their own translated elements around the form. This is hacky and not recommended for production use. Option 3: Wait for Enhanced Customization The Wasp team has acknowledged the need for more customization options for auth forms. There's an open GitHub issue (#1617) to make the signup form more flexible in future versions. For now, the best approach is likely Option 1 - creating your own forms using Wasp's auth primitives, which gives you full control over all text elements while still leveraging Wasp's authentication logic. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Gus, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Gus
GusOP•2w ago
@kapa.ai I went the custom form route, but then how can I correctly add the Google Auth option?
kapa.ai
kapa.ai•2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I can help you add Google Auth to your custom form. Wasp provides specific UI helpers for social authentication that you can use in your custom implementation. Adding Google Auth to Your Custom Form You can use the built-in Google sign-in button or URL provided by Wasp:
import {
GoogleSignInButton,
googleSignInUrl
} from 'wasp/client/auth'

// In your custom form component:
export function CustomLoginForm() {
return (
<div>
{/* Your custom username/password form */}
<form>
{/* ... your form fields ... */}
</form>

{/* Add Google auth using the pre-built button */}
<GoogleSignInButton />

{/* OR create your own custom button */}
<a href={googleSignInUrl}>
<button>Custom Google Sign In</button>
</a>
</div>
)
}
import {
GoogleSignInButton,
googleSignInUrl
} from 'wasp/client/auth'

// In your custom form component:
export function CustomLoginForm() {
return (
<div>
{/* Your custom username/password form */}
<form>
{/* ... your form fields ... */}
</form>

{/* Add Google auth using the pre-built button */}
<GoogleSignInButton />

{/* OR create your own custom button */}
<a href={googleSignInUrl}>
<button>Custom Google Sign In</button>
</a>
</div>
)
}
The GoogleSignInButton is a pre-styled button that handles the Google authentication flow, while googleSignInUrl is the URL that initiates the Google OAuth process, which you can use with your own custom button or link Auth Social Overview. Setting Up Google Auth in Your Wasp File Make sure you've properly configured Google Auth in your main.wasp file:
app myApp {
wasp: {
version: "^0.13.0"
},
title: "My App",
auth: {
userEntity: User,
methods: {
google: {}
},
onAuthFailedRedirectTo: "/login"
},
}
app myApp {
wasp: {
version: "^0.13.0"
},
title: "My App",
auth: {
userEntity: User,
methods: {
google: {}
},
onAuthFailedRedirectTo: "/login"
},
}
This enables Google authentication with the default settings Google Auth Setup. Customizing the Google Auth Flow If you need to customize the Google authentication flow (like adding extra user fields during signup), you can use the userSignupFields option:
// In main.wasp
app myApp {
// ...
auth: {
userEntity: User,
methods: {
google: {
userSignupFields: import { userSignupFields } from "@src/auth/google.js"
}
},
onAuthFailedRedirectTo: "/login"
},
}

// In src/auth/google.js
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
// Add custom fields or logic here
})
// In main.wasp
app myApp {
// ...
auth: {
userEntity: User,
methods: {
google: {
userSignupFields: import { userSignupFields } from "@src/auth/google.js"
}
},
onAuthFailedRedirectTo: "/login"
},
}

// In src/auth/google.js
import { defineUserSignupFields } from 'wasp/server/auth'

export const userSignupFields = defineUserSignupFields({
// Add custom fields or logic here
})
This allows you to customize how user data is processed during the Google authentication flow Google Auth API Reference. Remember that you'll need to create a Google OAuth app and configure it properly as described in the Wasp documentation for Google Auth. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Gus, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Vinny (@Wasp)
Vinny (@Wasp)•2w ago
Hey @Gus is the bot answering your questions or do you need some human assistance?
Gus
GusOP•2w ago
hey @Vinny (@Wasp) thanks for reaching out, the bot is fantastic, he's steering me in the right direction 😄
Vinny (@Wasp)
Vinny (@Wasp)•2w ago
Ok cool. Let us know if you need any help aside from that :godfatherboi:

Did you find this page helpful?