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
771stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity32
Maintenance12
Community44
Maturity44
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture85
Code Quality72
Innovation82
Learning Curve80

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 26 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
TypeScript
49%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,248

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript49%
Rust22%
Python16%
Updated today
TypeScript
97%
Apache 2.0

Cline

AI Code Assistants

66,453

An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.

View details
90
Repo Health
74
Technical
67
Dependency
Built with
TypeScript97%
Updated today
TypeScript
75%
Other

Jan

AI Assistants

44,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript75%
Rust21%
Updated today
TypeScript
69%
Apache 2.0

Laminar

AI Development · Monitoring

3,180

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
70
Dependency
Built with
TypeScript69%
Rust29%
Updated yesterday
Python
68%
MIT

Langflow

AI Agents · AI Development

153,450

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
66
Dependency
Built with
Python68%
TypeScript22%
Updated today
TypeScript
100%
MIT

Llama Coder

AI Development · Low Code Platforms

7,115

Generate multi-file web apps from a single prompt using open-source LLMs — an open-source alternative to Claude Artifacts.

View details
71
Repo Health
66
Technical
73
Dependency
Built with
TypeScript100%
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

Search