Composables

usePdfKitPageNavigation

Page navigation utilities.

Provides page navigation utilities.

Usage

const {
  currentPage,
  goToPage,
  nextPage,
  prevPage,
  firstPage,
  lastPage,
  canGoNext,
  canGoPrev,
} = usePdfKitPageNavigation({ totalPages: 100 })

Options

usePdfKitPageNavigation({
  totalPages: 100,  // required
  initialPage: 1,
})
OptionTypeDefaultDescription
totalPagesnumberrequiredTotal number of pages
initialPagenumber1Initial page number

totalPages is a required option. Calling the composable without it will not work — pass the document page count explicitly. :::

Return Values

PropertyTypeDescription
currentPageRef<number>Current page number
goToPage(page: number) => voidNavigate to page
nextPage() => voidGo to next page
prevPage() => voidGo to previous page
firstPage() => voidGo to first page
lastPage() => voidGo to last page
canGoNextComputedRef<boolean>Can go to next page
canGoPrevComputedRef<boolean>Can go to previous page

Example

<template>
  <div class="flex items-center gap-2">
    <UButton :disabled="!canGoPrev" @click="prevPage">
      Previous
    </UButton>
    <span>{{ currentPage }} / {{ totalPages }}</span>
    <UButton :disabled="!canGoNext" @click="nextPage">
      Next
    </UButton>
    <UInput 
      type="number" 
      :model-value="currentPage"
      @change="goToPage(Number($event.target.value))"
    />
  </div>
</template>

<script setup>
const totalPages = 100

const {
  currentPage,
  goToPage,
  nextPage,
  prevPage,
  canGoNext,
  canGoPrev,
} = usePdfKitPageNavigation({ totalPages })

const firstPage = () => goToPage(1)
const lastPage = () => goToPage(totalPages)
</script>
Copyright © 2026