User Management
1 Object type
Follow the steps below to install this Block. Make sure you have reviewed the getting started steps.
This will create the users Object type in your Bucket.
This will add the components SignUpClient.tsx, LoginClient.tsx, ForgotPasswordForm.tsx, etc. and actions.ts server actions file to your blocks folder located in cosmic/blocks/user-management.
We will use the Resend email service to send emails (installed automatically). Learn more about sending emails with Resend on the Resend website. Add the following keys to the `.env.local` file. Change the values to your Resend key and app details. Find your Resend API key in the Resend dashboard.
Add the AuthProvider component to your layout.tsx file. This will provide the auth context to your app.
Create a new file at app/signup/page.tsx and add the following code. Then go to http://localhost:3000/signup to see the form.
Create a new file at app/forgot-password/page.tsx and add the following code.
Create a new file at app/reset-password/page.tsx and add the following code.
Create a new file at
app/dashboard/page.tsx
and add the following code. This uses the auth context to check if the user is logged in and fetches the user data from Cosmic. Note: You will need to add imgix.cosmicjs.com
to the images
section of your next.config.ts
file to enable the avatar image. For larger images, you will need to enable larger body sizes for server actions. See the Next.js docs for more details.Add the AuthButtons component to your navigation menu. This will show the login/logout buttons and user dashboard menu items.
Check out a full-featured working example Cosmic Podcast Network.
More to explore
Landing Page
1 Object type • 1 demo Object
Layout
2 Object types • 3 demo Objects
Blog
3 Object types • 2 demo Objects
Comments
1 Object type • 5 demo Objects
Contact Form
1 Object type
Events
1 Object type • 3 demo Objects
Ecommerce
1 Object type • 4 demo Objects
Videos
3 Object types • 9 demo Objects
Team
1 Object type • 4 demo Objects
Testimonials
1 Object type • 4 demo Objects
FAQs
1 Metafield
Image Gallery
1 Metafield
Navigation Menu
1 Object type • 2 demo Objects
SEO Fields
1 Metafield
Pagination
No content installed
Localization
No content installed
File Upload
No content installed
User Management
1 Object type