<?php
$pagination = get_the_posts_pagination( array(
'mid_size' => 2,
'prev_text' => __( 'Newer', 'textdomain' ),
'next_text' => __( 'Older', 'textdomain' ),
) );
?>
https://codex.wordpress.org/Function_Reference/get_the_posts_pagination