
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@solid-primitives/pagination
Advanced tools
A primitive that creates all the reactive data to manage your pagination.
A primitive that creates all the reactive data to manage your pagination:
createPagination - Provides an array with the properties to fill your pagination with and a page setter/getter.createSegment - Provides a reactive segment of an array (e.g. a page of a number of items).createInfiniteScroll - Provides an easy way to implement infinite scrolling.npm install @solid-primitives/pagination
# or
yarn add @solid-primitives/pagination
# or
pnpm add @solid-primitives/pagination
createPaginationProvides an array with the properties to fill your pagination with and a page setter/getter.
type PaginationOptions = {
/** the overall number of pages */
pages: number;
/** the highest number of pages to show at the same time */
maxPages?: number;
/** start with another page than `1` */
initialPage?: number;
/** show an element for the first page */
showFirst?: boolean | ((page: number, pages: number) => boolean);
/** show an element for the previous page */
showPrev?: boolean | ((page: number, pages: number) => boolean);
/** show an element for the next page */
showNext?: boolean | ((page: number, pages: number) => boolean);
/** show an element for the last page */
showLast?: boolean | ((page: number, pages: number) => boolean);
/** content for the first page element, e.g. an SVG icon, default is "|<" */
firstContent?: JSX.Element;
/** content for the previous page element, e.g. an SVG icon, default is "<" */
prevContent?: JSX.Element;
/** content for the next page element, e.g. an SVG icon, default is ">" */
nextContent?: JSX.Element;
/** content for the last page element, e.g. an SVG icon, default is ">|" */
lastContent?: JSX.Element;
/** number of pages a large jump, if it should exist, should skip */
jumpPages?: number;
};
// Returns a tuple of props, page and setPage.
// Props is an array of props to spread on each button.
// Page is the current page number.
// setPage is a function to set the page number.
const [props, page, setPage] = createPagination({ pages: 3 });
While the preferred structure is links or buttons (if only client-side) inside a nav element, you can use arbitrary components, e.g. using your favorite UI component library (as long as it supports the same handlers and properties as DOM nodes, which it probably should). The props objects for each page will be reused in order to grant maximum performance using the <For> flow component to iterate over the props:
const [paginationProps, page, setPage] = createPagination({ pages: 100 });
createEffect(() => {
/* do something with */ page();
});
return (
<nav class="pagination">
<For each={paginationProps()}>{props => <button {...props} />}</For>
</nav>
);
In order to allow linking the pages manually, there is a non-enumerable page property in the props object:
const [paginationProps, page, setPage] = createPagination({ pages: 100 });
createEffect(() => {
/* do something with */ page();
});
return (
<nav class="pagination">
<ul>
<For each={paginationProps()}>
{props => (
<li>
<A href={`?page=${props.page}`} {...props} />
</li>
)}
</For>
</ul>
</nav>
);
createSegmentIt is a common requirement to put multiple items on a single page, which exactly is what createSegment is for.
const segment = createSegment(items, limit, page);
return <For each={segment()}>{item => <Item item={item} />}</For>;
items can be any array of items or an accessor with an array of items; even if the array increases in size, the segment will only change if the growth brings an actual changelimit is the limit for the number of items within a segment; this can be a number or an accessor containing a numberpage is an accessor with the number or the segment page, starting with 1You may view a working example here: https://primitives.solidjs.community/playground/pagination/
createInfiniteScrollCombines createResource with IntersectionObserver to provide an easy way to implement infinite scrolling.
// fetcher: (page: number) => Promise<T[]>
const [pages, setEl, { end }] = createInfiniteScroll(fetcher);
return (
<div>
<For each={pages()}>{item => <h4>{item}</h4>}</For>
<Show when={!end()}>
<h1 ref={setEl}>Loading...</h1>
</Show>
</div>
);
Or as a directive:
const [pages, infiniteScrollLoader, { end }] = createInfiniteScroll(fetcher);
return (
<div>
<For each={pages()}>{item => <h4>{item}</h4>}</For>
<Show when={!end()}>
<h1 use:infiniteScrollLoader>Loading...</h1>
</Show>
</div>
);
function createInfiniteScroll<T>(fetcher: (page: number) => Promise<T[]>): [
pages: Accessor<T[]>,
loader: Directive<true>,
options: {
page: Accessor<number>;
setPage: Setter<number>;
setPages: Setter<T[]>;
end: Accessor<boolean>;
setEnd: Setter<boolean>;
},
];
See CHANGELOG.md
FAQs
A primitive that creates all the reactive data to manage your pagination.
The npm package @solid-primitives/pagination receives a total of 509 weekly downloads. As such, @solid-primitives/pagination popularity was classified as not popular.
We found that @solid-primitives/pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.