use-stick-to-bottom

Zero-dependency React hook and component that keeps AI chat scrolled to the bottom as content streams in.

Library
npm
v1.1.6
785 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
34 /100 Needs Attention
Development Activity 8
Maintenance 0
Community 44
Maturity 44
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 85
Code Quality 72
Innovation 82
Learning Curve 80

use-stick-to-bottom is a lightweight, zero-dependency React hook and companion component designed for AI chat interfaces, where new messages and streamed tokens continuously grow the message list. It automatically keeps the scroll container pinned to the bottom and smoothly animates content into place, while letting users escape the lock the moment they scroll up.

Built on the modern ResizeObserver API rather than CSS overflow-anchor, it works consistently across browsers (including Safari), handles content that both grows and shrinks, and correctly manages scroll anchoring so off-screen resizes don’t cause visible jumps. A custom velocity-based spring animation makes streaming content feel natural instead of relying on fixed-duration easing.

What You Get

  • A useStickToBottom hook that returns scrollRef and contentRef to wire up any existing scroll container
  • A ready-made StickToBottom component with a Content subcomponent and React context so children can read isAtBottom and call scrollToBottom
  • A custom velocity-based spring scrolling animation with configurable damping, stiffness, and mass
  • Automatic user-escape detection that cancels stickiness when the user scrolls up, without debouncing
  • Correct scroll-anchoring behavior so content resizing above the viewport doesn’t cause visible jumps

Common Use Cases

  • Keeping an AI chatbot conversation pinned to the latest streamed tokens
  • Auto-scrolling a live log or terminal output view as new lines arrive
  • Maintaining bottom position in a real-time messaging or comments feed
  • Adding a scroll-to-bottom button that appears only when the user has scrolled away

Under The Hood

Architecture

The package is split into three source files under src/: useStickToBottom.ts holds the core logic, StickToBottom.tsx wraps it in a component plus React context, and index.ts re-exports both. The hook manages a rich mutable StickToBottomState (scrollTop, targetScrollTop, velocity, escapedFromLock, isAtBottom, and a live ResizeObserver) held in refs to avoid re-renders, and drives a custom animation loop via requestAnimationFrame. A ResizeObserver on the content element detects growth and shrinkage, recomputes the target scroll position, and either snaps or spring-animates toward it; scrollToBottom returns a Promise<boolean> that resolves true on success or false if the scroll is cancelled by the user scrolling up.

Tech Stack

Written in TypeScript (~97% of the codebase) with zero runtime dependencies and a single peer dependency on React (^16.8 through ^19). It builds to ESM with tsc -b and vite-plugin-dts for type declarations, uses Biome for linting/formatting, and ships a Vite + Tailwind demo app. It relies only on standard browser APIs (ResizeObserver, requestAnimationFrame) rather than CSS overflow-anchor.

Code Quality

The code is strongly typed with exported interfaces for state, options, spring parameters, and the context, and uses an isomorphic layout-effect guard for SSR safety. Logic is dense but well-commented, with documented defaults for the spring animation. There is no automated test suite in the repository; correctness is exercised through the interactive demo app rather than unit tests, which is the main quality gap.

API Design

The public surface is deliberately small and ergonomic: a hook returning refs for full control, or a drop-in StickToBottom/StickToBottom.Content component pair plus a useStickToBottomContext hook for children. Options like resize, initial, and per-call scroll behavior are consistently named, and JSDoc on options documents defaults inline, making it approachable for common chat use cases with minimal boilerplate.

Used by 27 apps in this directory

JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
TypeScript
99%
Other

Papermark

Digital Signiture · File Storage

9,263

Open-source DocSend alternative with page-by-page analytics, secure data rooms, and custom domains for document sharing.

View details
78
Repo Health
63
Technical
66
Dependency
Built with
TypeScript 99%
Updated 2 months ago
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,976

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated 5 days ago
TypeScript
98%
Apache 2.0

rowboat

AI Assistants · AI Development

18,060

Build, test, and deploy multi-agent AI workflows with a visual editor, RAG data sources, MCP tool integration, and a production-ready REST API.

View details
88
Repo Health
72
Technical
65
Dependency
Built with
TypeScript 98%
Updated 6 days ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
TypeScript
72%
Apache 2.0

Supabase

Authentication · Databases · Developer Tools

113,827

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript 72%
MDX 26%
Updated 5 days ago
TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 5 days ago
TypeScript
98%
Apache 2.0

Tianji

Analytics · Monitoring

3,119

Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.

View details
86
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
Python
68%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,860

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 68%
TypeScript 30%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers