Why Use User Accounts
User Accounts offer several benefits:- Private pages - Require sign-in to view certain Pages
- Protected actions - Gate Functions behind authentication
- Personalization - Store and show user-specific content in Databases
- Grow your users - Let people sign up and join your community
Getting Started
Enable User Accounts in two steps:-
Enable for Project:
- Open Create logo menu
- Choose “Enable User Accounts”
- Signup, Signin, Logout pages and a Users database gets created automatically
-
Protect Content:
- Open page/function settings (3-dot menu > Settings > “Require sign in to view”)
- Enable “Require sign in to view”
- Publish to apply changes
How Authentication Works
When you enable User Accounts, Create adds:-
Authentication Pages:
-
/account/signin- Sign in page -
/account/signup- Sign up page -
/account/logout- Logout page - Link to these pages directly for custom flows
-
-
Users Database:
- Stores user accounts automatically
- Built-in fields: email, password (hashed)
- Add custom fields as needed using Databases
-
Access Control:
- Protected pages redirect to sign in
- After auth, users return to original page
- Functions can check user status
- Link between pages normally - auth handles protection
Create handles auth redirects automatically. Link pages as you normally would - the auth system manages access control.
How It Works Under The Hood
Create uses JWT (JSON Web Token) authentication to manage user sessions:- When users sign up or sign in, Create stores a secure cookie in their browser
- This cookie keeps users logged in as they browse your app
- When users visit a protected page or use a protected function, Create checks this cookie
- If no valid cookie exists, Create redirects them to the sign-in page
-
To let users log out, add a link to
/account/logoutin your app’s signed-in experience - When users visit the logout page, Create removes the cookie and ends their session
Real World Example
Let’s say you have an AI app with:-
Landing page (at
/) -
AI homework creator (at
/app)
- Enable User Accounts for the project
-
Go to
/apppage > 3-dot menu > Settings > “Require account to view” - Publish changes
-
Now:
-
/remains public -
/appredirects to sign-in -
After sign-in, users access
/app - Add personalization: “When user is logged in, show their profile in top right and store their AI generations in GenerationsDB with their user ID”
-
Using User Data
Access user information in two ways:-
Direct References:
- Use “signed in user” in prompts
- Example: “Show current user’s email in header”
- Create handles the code automatically
-
Database Queries:
- Query Users database like any other database
- Join with other databases using user ID
- Store user-specific data in related tables
Roles and Permissions
Add custom roles to control access:-
Add Role Field:
- Update Users database schema
- Add “role” or similar field
- Set values like “admin”, “member”
-
Check Roles:
- Reference roles in prompts
- Example: “If signed in user is admin, show settings”
- Create handles the logic
Testing
Verify your User Accounts setup:- Enable auth on a test page
- Publish changes
- Open an incognito window
- Verify redirect to sign-in
- Create test account
- Confirm access after auth
Troubleshooting
If authentication isn’t working:- Verify User Accounts is enabled for project
- Check page/function auth settings
- Review Users database contents
- Test with a fresh account
- Join our Discord for help
FAQs
Can I customize the sign-in page?
Can I customize the sign-in page?
Not yet, but it’s on our roadmap.
Can I add social login (Google, Facebook)?
Can I add social login (Google, Facebook)?
Can I add fields beyond email?
Can I add fields beyond email?
Yes! Update the Users database or create related databases to store additional user information.
See Also
- Databases - Store user data and content
- Functions - Add custom authentication logic that looks at the UserDB to do different actions
- Pages - Create protected routes
- Publishing - Deploy your authenticated app