Pagination Using $wpdb variable

            global $wpdb;
            $pageNum = filter_input(INPUT_GET, 'pagenum') ? absint(filter_input(INPUT_GET, 'pagenum')) : 1;
            $limit = 2; // number of rows in page  
            $one = 1;
            $offset = ($pageNum - $one) * $limit;
            $total = $wpdb->get_var("SELECT COUNT(`id`) FROM the_directory");
            $num_of_pages = ceil($total / $limit);
            $sql = "SELECT * FROM `the_directory` LIMIT $offset, $limit";
            $res = $wpdb->get_results($sql);
            foreach ($res as $r) {
                       //Display Table Data Here
            }
         
        $page_links = paginate_links(array(
                'base' => add_query_arg('pagenum', '%#%'),
                'format' => '',
                'prev_text' => __('«', 'aag'),
                'next_text' => __('»', 'aag'),
                'total' => $num_of_pages,
                'current' => $pageNum,
                'base' => add_query_arg('pagenum', '%#%'),
                'format' => '',
                'prev_next' => true,
                'prev_text' => __('←', 'aag'),
                'next_text' => __('→', 'aag'),
                'before_page_number' => '<li><span class="page-numbers btn btn-pagination btn-tb-primary">',
                'after_page_number' => '</span></li>'
            ));

    if ($page_links) {

        echo '<div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div>';
    }
            

Pagination Using wp_query()

<div id="contents">
<?php
                    $args = array(
                        'post_type' => 'post',
                        'posts_per_page' => 10,
                        'paged' => get_query_var('paged') ? get_query_var('paged') : 1
                    );
                    $resData = new WP_Query($args);
                    if ($resData->have_posts()) :
                        while ($resData->have_posts()) :
                            $resData->the_post();
                          /*
                           * Title Description goes here
                           */
                     endwhile;
                    endif;
               
                $total_pages = $resData->max_num_pages; 
                if ($total_pages > 1) {
                    $current_page = max(1, get_query_var('paged'));
                    $pages = paginate_links(array(
                        'base' => get_pagenum_link(1) . '%_%',
                        'format' => '/page/%#%',
                        'current' => $current_page,
                        'total' => $total_pages,
                        'prev_text' => __('Previous'),
                        'next_text' => __('Next'),
                    ));
                }
                if (!is_array($pages)) {
                    ?>
                    <div id="pagination" class="col-md-12 st-pagination">
                        <ul class="pagination">
                            <?php
                            echo "<li>" . $pages . "</li>";
                            ?>

                        </ul>
                    </div>
                <?php } ?>      
</div>

You can also use simple ajax for pagination

<div id="loading" style="display:none;"> 
    <img src="https://thumbs.gfycat.com/AggressiveGrouchyHammerkop-size_restricted.gif" title="loading" />
</div>
// Using AJAX
 $(document).ready(function(){
        jQuery(function($) {
            $('.recipe-results').on('click', '#pagination a', function(e){
               $('#loading').show();
                e.preventDefault();
                var link = $(this).attr('href');
                $('.recipe-results').animate({opacity:0.1}, 200, function(){
                    $(this).load(link + ' .recipe-results', function() {
                     $('#loading').hide();
                        $(this).animate({opacity: 1},200);
                    });
                });
            });
        });
    });