While DynamoDB will Paginate your data in forward direction only, You'll have to deal with the Backward Pagination in Front End. 
For large Tables (exceeding 1MB size), what DynamoDB does:
- Scans or Queries upto 1MB.
 
- Returns LastEvaluatedKeyto fetch the next set of data or the Next Page. This value is used as Pagination Key in Front End to paginate back and forth.
LastEvaluatedKey holds the value of the last object fetched from DynamoDB during a Scan or Query.
What you need to do (in Back End):
- Use LIMITproperty ofDynamoDB Queryto specify you want only 20 items.
 
- Use ExclusiveStartKeyproperty ofDynamoDB Queryto specify that next set of data would start from the specified value of this property.
What you need to do (in Front End):
- Keep an array of objects - arr[]to host Pagination Keys.
 
- Keep a variable - pageinitialized to -1, whose value will indicate the current page user is on.
 
- Load the initial page of list into the UI. Now alongside the data, if you have LastEvaluatedKey, push it into thearrand incrementpage.
Now, you have a single page and page indicates you're on
  Page 0 and arr contains Page Key of next page.
- Code of - NextButton should follow the logic:
 - Request your server to fetch the next page using ExclusiveStartKey = - arr[- page]
 
- When results of next page arrives, you'll again have another - LastEvaluatedKey, so again push it into- arrand increment- page. So you get the picture here, how we save the Page Keys.
 
- Code of - BackButton should follow the logic:
 - Since - pagevariable indicates the Current Page so- page - 1would indicate the previous page. So:
 if (- page-1>=0) Request your server to fetch the next page using ExclusiveStartKey =- arr[- page - 1]
 
You'll have to manage when Back & Next Buttons are available for clicking by using arr[] and page variables after each page is fetched.