#

# Quick Start


# 1. Install

Prevent unexpected breaking changes in stable releases (see omit the patch version):

Gemfile (stable)
gem 'pagy', '~> 43.0' # Omit the patch segment to avoid breaking changes

Enable pre-release versions. For example:

Gemfile (pre-release)
gem 'pagy', '43.0.0.pre123'  # Only the specific pre-release (change to upgrade)
gem 'pagy', '~> 43.0.0.pre'  # From the last pre-release up-to the SAME FIRST stable version (x.0.0)
gem 'pagy', '~> 43.0.pre'    # Same as '~> 43.0' above, but including the pre-releases

# 2. Use it in your app

  • Include the pagy method where you are going to use it (usually ApplicationController):

    include Pagy::Method
  • Use it to paginate any collection with any technique:

    @pagy, @records = pagy(:offset, Product.some_scope, **options) # :offset paginator
    @pagy, @records = pagy(:keyset, Product.some_scope, **options) # :keyset paginator
    @pagy, @records = pagy(...)

    See all the available paginators

  • Render navigator tags and other helpers with the @pagy instance methods:

    <%# Render navigation bar helpers with various types and styles %>
    <%== @pagy.series_nav %>
    <%== @pagy.series_nav_js(:bootstrap) %>
    <%== @pagy.input_nav_js(:bulma) %>
    <%== @pagy.info_tag %>

    See all the available @pagy methods

# 3. Configure global options and special features

# Pick a stylesheet or a CSS framework

  • For native pagy helpers you can integrate the Stylesheets (CSS or Tailwind) into your app.
  • For :bootstrap and :bulma styles, no additional CSS file is needed.

# If you use any *_js method...