You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/[platform]/build-a-backend/auth/customize-auth-lifecycle/email-customization/index.mdx
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,9 +31,32 @@ export function getStaticProps() {
31
31
{/* verification email (basic) */}
32
32
{/* verification email with react.email/jsx.email */}
33
33
34
+
## Customize the Verification Email
35
+
34
36
By default, Amplify Auth resources are scaffolded with email as the default method for your users to sign in. When you users sign up they receive a verification email to confirm their ownership of the email they specified during sign-up. Emails such as the verification email can be customized with your app's brand identity.
35
37
36
-
To get started, modify `email: true` to an object to begin customizing its default behavior:
38
+
To get started, change the `email` attribute of `loginWith` from `true` to an object to begin customizing its default behavior:
39
+
40
+
```diff title="amplify/auth/resource.ts"
41
+
import { defineAuth } from "@aws-amplify/backend"
42
+
43
+
export const auth = defineAuth({
44
+
loginWith: {
45
+
- email: true,
46
+
+ email: {
47
+
+ verificationEmailStyle: "CODE",
48
+
+ verificationEmailSubject: "Welcome to my app!",
49
+
+ verificationEmailBody: (createCode) => `Use this code to confirm your account: ${createCode()}`,
50
+
+ },
51
+
},
52
+
})
53
+
```
54
+
55
+
## Customize the Invitation Email
56
+
57
+
In some cases, you may [set up a user account on behalf of a user in the Amplify console](/[platform]/build-a-backend/auth/manage-users/with-amplify-console/). In this case, Amplify Auth will send an invitation email to the user welcoming them to your application. This email includes a brief welcome message, along with the email address they can log in with and the temporary password you've set up for them.
58
+
59
+
If you'd like to customize that email, you can override the `userInvitation` attribute of the `email` object:
+ // can be used in conjunction with a customized welcome email as well
45
69
+ verificationEmailStyle: "CODE",
46
70
+ verificationEmailSubject: "Welcome to my app!",
47
71
+ verificationEmailBody: (createCode) => `Use this code to confirm your account: ${createCode()}`,
72
+
+ userInvitation: {
73
+
+ emailSubject: "Welcome to my app!",
74
+
+ emailBody: (user, code) =>
75
+
+ `We're happy to have you! You can now login with username ${user()} and temporary password ${code()}`,
76
+
+ },
48
77
+ },
49
78
},
50
79
})
51
80
```
52
81
82
+
Note that when using the `user` and `code` arguments of the `emailBody` function, `user` and `code` are **functions** which must be called. Failure to call them will result in an error when your sandbox deploys.
0 commit comments