This guide will walk you through setting up authentication with Appwrite for recode.
- An Appwrite account (sign up at https://cloud.appwrite.io)
- Node.js and npm installed
- Go to Appwrite Cloud Console
- Click "Create Project"
- Name your project (e.g., "recode")
- Copy the Project ID - you'll need this later
- In your Appwrite Console, go to Auth → Settings
- Go to Auth methods
- Find Email/Password and enable it
- In Appwrite Console, go to Databases
- Click "Create Database"
- Name it "codevault" (or your preferred name)
- Copy the Database ID
- Click on your newly created database
- Click "Create table"
- Name it "snippets"
- Copy the Table ID
Add the following attributes:
| Attribute | Type | Size | Required | Array |
|---|---|---|---|---|
| title | String | 255 | Yes | No |
| code | String | 10000 | Yes | No |
| language | String | 50 | Yes | No |
| tags | String | 50 | Yes | Yes |
- Go to the Settings tab of your table
- Under Permissions, add:
- Create: Role: Users (authenticated users)
- Go to the Row security tab
- Enable Row security
-
Copy
.env.exampleto.env.local:cp .env.example .env.local
-
Fill in your values in
.env.local:NEXT_PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1 NEXT_PUBLIC_APPWRITE_PROJECT_ID=your_project_id_here NEXT_PUBLIC_APPWRITE_DATABASE_ID=your_database_id_here NEXT_PUBLIC_APPWRITE_SNIPPETS_TABLE_ID=your_snippets_table_id_here
- Start your development server:
npm run dev- Open
http://localhost:3000and use the Sign up / Sign in form with an email and password. - If verification is enabled, confirm the verification email and ensure the app accepts the verified user.
- Test the password reset flow (Forgot password) to ensure recovery links open the app's reset page.
- User unauthorized: check database/table permissions and row-level security settings.
- Environment variables missing: ensure
.env.localis populated and restart the dev server.
When deploying to production:
- Add your production domain in the Appwrite Console (Platforms) so redirect URLs work.
- Set the production environment variables in your hosting platform (preferably Appwrite Sites).
- Test sign-up, verification, and password recovery flows against the production domain.
If you encounter issues:
- Check the browser console for errors
- Check Appwrite logs in the Console
- Verify all IDs and secrets are correct