Skip to content

Add anonymous session support to Login page#245

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-anonymous-sign-in-support
Draft

Add anonymous session support to Login page#245
Copilot wants to merge 4 commits intomainfrom
copilot/add-anonymous-sign-in-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 30, 2025

Adds anonymous authentication via Appwrite's account.createAnonymousSession() API alongside existing email/password and guest modes.

Changes

  • src/pages/Login.tsx
    • Added onSignInAnonymously handler that creates an Appwrite anonymous session, stores credentials in localStorage, and invalidates user query cache
    • Added "Sign in anonymously" button (pink outline) next to "Continue as Guest" button (pink solid) using HStack layout
    • Fixed button types from type="submit" to type="button" to prevent form submission conflicts

Implementation

const onSignInAnonymously = async (values: IFormInput) => {
  const { endpoint, project } = values;
  const { client } = props;

  client.setEndpoint(endpoint);
  client.setProject(project);

  const account = new Account(client);

  try {
    await account.createAnonymousSession();
    localStorage.setItem(LocalStorageKey.ENDPOINT, endpoint);
    localStorage.setItem(LocalStorageKey.PROJECT, project);
    queryClient.invalidateQueries(QueryKey.USER);
    toast({ /* success notification */ });
  } catch (error) {
    toast({ /* error notification */ });
  }
};

UI

The new button creates an actual Appwrite session unlike the guest mode which mocks user data locally.

Original prompt

Add anonymous sign-in support to the Login page in stnguyen90/appwrite-explorer.

Changes to make:

  1. Update src/pages/Login.tsx to add an anonymous sign-in handler that calls account.createAnonymousSession(), stores endpoint and project in localStorage, invalidates QueryKey.USER, and shows toast on success/failure. Add a "Sign in anonymously" button next to the existing Sign in and Continue as Guest buttons (use existing handleSubmit wiring).
  2. Ensure imports include any new Chakra components used (HStack) and maintain TypeScript types.
  3. Keep existing behavior for email/password sign-in and guest continue.

Requirements:

  • Follow the project's coding style and TypeScript types.
  • Add unit tests are not required.
  • Target branch: main (create a feature branch for the change).

Files to modify:

  • src/pages/Login.tsx (replace with updated content to implement anonymous login)

Provide a Pull Request with a descriptive title and body describing the change and reasons.

This pull request was created as a result of the following prompt from Copilot chat.

Add anonymous sign-in support to the Login page in stnguyen90/appwrite-explorer.

Changes to make:

  1. Update src/pages/Login.tsx to add an anonymous sign-in handler that calls account.createAnonymousSession(), stores endpoint and project in localStorage, invalidates QueryKey.USER, and shows toast on success/failure. Add a "Sign in anonymously" button next to the existing Sign in and Continue as Guest buttons (use existing handleSubmit wiring).
  2. Ensure imports include any new Chakra components used (HStack) and maintain TypeScript types.
  3. Keep existing behavior for email/password sign-in and guest continue.

Requirements:

  • Follow the project's coding style and TypeScript types.
  • Add unit tests are not required.
  • Target branch: main (create a feature branch for the change).

Files to modify:

  • src/pages/Login.tsx (replace with updated content to implement anonymous login)

Provide a Pull Request with a descriptive title and body describing the change and reasons.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@appwrite
Copy link
Copy Markdown

appwrite bot commented Oct 30, 2025

delete

Project ID: delete

Sites (1)
Site Status Logs Preview QR
 appwrite-explorer
6895711300041d1f243c
Ready Ready View Logs Preview URL QR Code

Tip

Build commands execute in runtime containers during deployment

Copilot AI and others added 2 commits October 30, 2025 14:29
Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
Copilot AI changed the title [WIP] Add anonymous sign-in support to Login page Add anonymous session support to Login page Oct 30, 2025
Copilot AI requested a review from stnguyen90 October 30, 2025 14:34
Comment thread src/pages/Login.tsx
Comment on lines +226 to +234
<Button
colorScheme="teal"
isLoading={isSubmitting}
type="button"
size="lg"
onClick={handleSubmit(onSignInAnonymously)}
>
Sign in anonymously
</Button>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot keep the same color scheme. make the variant outline.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in edadb0f — changed to colorScheme="pink" with variant="outline".

Updated UI

Co-authored-by: stnguyen90 <1477010+stnguyen90@users.noreply.github.com>
Copilot AI requested a review from stnguyen90 March 19, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants