How to add custom button on sales order view admin page Magento 2?

Add Custom Button on Sales Order View Page on the admin panel toolbar Magento to add extra features to the order view page.

Using Button, You can add URL to redirect to another page with your custom requirement.

To add a custom button, you need to create before plugin for the PushButtons() method from the Magento\Backend\Block\Widget\Button\Toolbar class.

Create di.xml file under the adminhtml scope,
Path: app/code/Jesadiya/OrderViewButton/etc/adminhtml/di.xml

<?xml version="1.0"?>
<config xmlns:xsi=""
    <!-- Add new Button on sales order view toolbar -->
    <type name="Magento\Backend\Block\Widget\Button\Toolbar">
        <plugin name="add_sales_button_toolbar" type="Jesadiya\OrderViewButton\Plugin\Block\Widget\Button\ToolbarPlugin" />

Path: app/code/Jesadiya/OrderViewButton/Plugin/Block/Widget/Button/ToolbarPlugin.php

<?php declare(strict_types=1);

namespace Jesadiya\OrderViewButton\Plugin\Block\Widget\Button;

use Magento\Sales\Block\Adminhtml\Order\Create;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Backend\Block\Widget\Button\ButtonList;
use Magento\Backend\Block\Widget\Button\Toolbar as ToolbarContext;

class ToolbarPlugin
     * @param ToolbarContext $toolbar
     * @param AbstractBlock $context
     * @param ButtonList $buttonList
     * @return array
    public function beforePushButtons(
        ToolbarContext $toolbar,
        AbstractBlock $context,
        ButtonList $buttonList
    ): array {
        $order = false;
        $nameInLayout = $context->getNameInLayout();
        if ('sales_order_edit' == $nameInLayout) {
            $order = $context->getOrder();

        if ($order) {
        	$url = "YOUR_URL"; // add your full url
	                'label' => __('My Button'),
	            	'on_click' => sprintf("location.href = '%s';", $url),
	                'class' => 'primary',
	                'id' => 'my_button'

        return [$context, $buttonList];        

This is the plugin we made to add toolbar button on order view page, We are checking for the layout of sales_order_edit, if the layout is correct, we will add a button to the toolbar.

sales_order_edit is the layout responsible for the Render Content on the Order View Page.

Sales order toolbar admin panel
Sales Order Custom button on Toolbar

When you click on the My Button, It will be redirected to the given URL.

You can add the same button with Invoice, Shipping View Toolbar also using comparing layout of the respective page.

You can add a custom tab in Sales Order View by, Add tab in Admin Order view page.