Skip to content

Add cloud storage with GitHub and Google login - #231

Merged
pearmini merged 2 commits into
mainfrom
firebase-cloud-storage
Sep 13, 2026
Merged

pearmini merged 2 commits into
mainfrom
firebase-cloud-storage

Conversation

@pearmini

@pearmini pearmini commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

close: #107

Summary

Notebooks are now saved to Firebase (Firestore) instead of only localStorage, with login via GitHub or Google.

  • Login: a new icon at the far right of the nav opens "Continue with GitHub / Google". Once logged in, it shows the user's avatar with their email and "Log out". Login uses a popup, so an unsaved notebook stays on screen.
  • Saving requires login: when logged out, Create, Duplicate (including from Examples) and ⌘S open the login menu, then continue once the user has logged in.
  • Upload on login: existing localStorage notebooks are uploaded to the user's account, then cleared locally.
  • Logged out: local notebooks can still be opened and run from /works, but edits aren't saved and delete is hidden.
  • Autosave: edits and renames are written about 800 ms after the last change.
  • Freeze guard: the "don't auto-run a notebook that froze last time" guard now uses a local flag instead of writing autoRun on every run.

Implementation

  • app/firebase.js: lazy Firebase init, so server rendering never touches Firebase.
  • app/auth.js: auth store (same useSyncExternalStore pattern as app/store.js) and ensureUser().
  • app/api.js: notebook reads and writes are async and stored at users/{uid}/notebooks/{id}.
  • firestore.rules: users can only read and write their own notebooks.

Setup

  • The Firebase project is recho-dev, with GitHub and Google providers enabled.
  • The four NEXT_PUBLIC_FIREBASE_* variables are set in Vercel for all environments. See .env.example for local development.
  • Rules are deployed with firebase deploy --only firestore:rules.

Test plan

  • pnpm test:lint, pnpm test:typecheck, prettier check, vitest (187 tests)
  • pnpm app:build
  • Logged out: Create opens the login menu; local notebooks run but don't save
  • Log in with GitHub and Google; local notebooks are uploaded and localStorage is cleared
  • Edit, rename, duplicate and delete all persist after a reload
  • A second account can't see the first account's notebooks

🤖 Generated with Claude Code

Notebooks are saved to Firestore under the logged-in user. Local
notebooks are uploaded on login and then cleared; logged-out users can
view and run them but can't save.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
recho-notebook Ready Ready Preview Sep 13, 2026 4:41pm UTC

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unsaved edits can be overwritten or silently lost during login, autosave failures, and page unloads.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Firebase authentication and Firestore-backed notebook persistence, including local notebook migration and autosaving.

Changes:

  • Adds GitHub/Google login and account navigation.
  • Migrates notebook storage from localStorage to Firestore.
  • Adds debounced autosaving, migration, and freeze-state tracking.
File summaries
File Description
.env.example Documents Firebase configuration variables.
.firebaserc Selects the Firebase project.
.gitignore Excludes local Firebase artifacts and environment files.
app/EditorPage.jsx Integrates authentication, cloud loading, and autosaving.
app/Nav.jsx Adds the login and account menu.
app/api.js Implements Firestore persistence and local migration.
app/auth.js Adds authentication state and login flows.
app/examples/ExampleEditor.jsx Requires login before duplication.
app/firebase.js Lazily initializes Firebase services.
app/works/page.jsx Loads and deletes cloud notebooks.
firebase.json Configures Firestore rules deployment.
firestore.rules Restricts notebooks to their owners.
package.json Adds the Firebase dependency.
pnpm-lock.yaml Locks Firebase and transitive dependencies.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 12/14 changed files
  • Comments generated: 6
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/EditorPage.jsx
Comment thread app/EditorPage.jsx
Comment thread app/api.js Outdated
Comment thread app/EditorPage.jsx Outdated
Comment thread app/auth.js
Comment thread app/works/page.jsx Outdated
- Keep edits made while logged out on screen after login and save them.
- Retry failed autosaves and warn before closing the tab while edits are
  queued, being written, or waiting for a retry.
- Show a retryable error instead of a 404 or an empty list when loading
  from Firestore fails.
- Keep listing local notebooks that failed to upload, and never overwrite
  cloud notebooks when the upload is retried.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pearmini
pearmini merged commit 6269bb5 into main Sep 13, 2026
2 of 3 checks passed
@pearmini
pearmini deleted the firebase-cloud-storage branch September 13, 2026 16:52

This branch was successfully deployed

1 active deployment
Preview — 54136ae3 Deployed Sep 13, 2026 by vercel[bot]
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.

Cloud Storage Services

2 participants