Promise
A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
In more detail
Callbacks attached with then(), or code after await, run as microtasks once the promise settles. fetch, Cache Storage and many modern APIs return promises.
Examples
React can read a promise with the use API: while it is pending the component suspends and a Suspense fallback shows; a rejection goes to the nearest error boundary.Promises passed to use must be created outside rendering or cached, or a new one is made every render.Related terms
- microtask — A small job, such as a promise callback, that runs as soon as the current piece of JavaScript finishes, before the event loop handles anything else.
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
- asynchronous — Describes work that starts now and finishes later, letting the program do other things instead of waiting for it.
- Promise.allSettled — A JavaScript function that waits for every promise in a list to finish and reports each one’s result, whether it succeeded or failed.
- Promise.all — A JavaScript function that starts waiting on several Promises at once and resolves when all of them have finished.
- params — The object holding the values matched by a route's dynamic segments, such as { slug: 'hello' }.
- callback — A function you pass to other code so it can call you back later, for example when an event happens or a timer fires.
- unhandledRejection — The Node.js process event emitted when a promise is rejected and no handler catches it.
- use() — The React 19 API that reads a value from a Promise or a context, and unlike hooks may be called inside conditions and loops.
- Suspense — A React component that shows a fallback, such as a spinner or skeleton, while components inside it are waiting for something to load.
- cache — A store of earlier answers kept close to where they are needed so they can be reused instead of fetched or computed again.
- Awaited<T> — The utility type that unwraps a promise type to the value it resolves to, repeating through nested promises and thenables.
Taught in
- The Browser Event Loop: Call Stack, Microtasks And Macrotasks — Frontend Architecture & Web Platform
- Cancellation With AbortController And Async Signal Propagation — Frontend Architecture & Web Platform
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform
- API Gateway & BFF Patterns: Backend-for-Frontend — Production Full-Stack Engineering
- End-to-End Testing with Playwright: Multi-Tier Suites — Production Full-Stack Engineering
- App Router Architecture: Server-First Paradigms — Next.js 15 & Modern App Router Architecture
- Server Components: Async Execution & Constraints — Next.js 15 & Modern App Router Architecture
- Serialization Boundaries: Props & Server Guardrails — Next.js 15 & Modern App Router Architecture
- Dynamic Routes: Slugs & generateStaticParams — Next.js 15 & Modern App Router Architecture
- Granular Suspense: Resolving Waterfall Bottlenecks — Next.js 15 & Modern App Router Architecture
- Async Data Fetching: Parallel Requests & Preloading — Next.js 15 & Modern App Router Architecture
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Microtask Queues: process.nextTick vs Promise Timing — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture
- useEffect Lifecycle: Mount, Dependencies, And Cleanup Phases — React 19 & Modern Component Architecture
- useLayoutEffect vs useEffect: Painting And Synchronous Reads — React 19 & Modern Component Architecture
- Creating Event Listener Hooks with Clean Teardown Logic — React 19 & Modern Component Architecture
- useTransition: Non-Blocking State Updates for Fluid UI — React 19 & Modern Component Architecture
- useOptimistic: Instantaneous UI Updates with Rollback — React 19 & Modern Component Architecture
- The use() Hook: Reading Promises And Context Directly — React 19 & Modern Component Architecture
- Suspense Architecture: Promises, Fallbacks, And Co-ordination — React 19 & Modern Component Architecture
- Code-Splitting with React.lazy: Dynamic Imports And Chunks — React 19 & Modern Component Architecture
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture
- Union Utilities: Exclude, Extract, NonNullable And Awaited — Production TypeScript
- Function Utilities: ReturnType, Parameters And Constructor — Production TypeScript
- Conditional Types: Ternary Types And Type Inference With infer — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript
- The Spine Artifact: Generating Typed Models From OpenAPI — Production TypeScript