Skip to content

Refactor: split useNostr god-hook into focused hooks #6

Description

@satsdisco

Summary

useNostr.ts is 668 lines doing everything — auth, publishing, article fetching, relay management, zap verification. This makes it hard to reason about, test, and maintain.

Proposed Split

  • useAuth.ts — Login/logout, NIP-07/NIP-46/nsec/Android signer, session management
  • usePublish.ts — Article building, signing, relay publishing, zap-gated publishing
  • useArticles.ts — Fetching articles, drafts, profiles from relays
  • useRelays.ts — Relay list management, read/write relay preferences
  • Keep useNostr.ts as a thin orchestrator that composes the above

Principles

  • Each hook should be independently testable
  • Shared state (pubkey, signer) passed via context or composition
  • No circular dependencies between hooks

Acceptance Criteria

  • Each new hook is <200 lines
  • useNostr is a thin composition layer
  • All existing functionality preserved
  • ESLint passes
  • Build compiles cleanly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions