How to Get Last Order id in Magento 2?

Magento 2 Get Last order in any page using Checkout Session. You can fetch Last order id of order by Magento\Checkout\Model\Session Object.

You need to create __construct( ) function for define dependency of Session Class

<?php
    private $checkoutSession;

    /**
     * Constructor
     *
     * @param Session $checkoutSession
     */
    public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession
    ) {
        $this->checkoutSession = $checkoutSession;
    }

Call method to get last order id using below way,

$orderId = $this->checkoutSession->getData(‘last_order_id’);

$orderId is your recent order id for a store.