How can i get product id on product page without registry? Such as class registry is deprecated in magento 2.3
You can use a view model.
Vinal kopp, write a blog where he has to create a custom registry but note that registry, not Magento generic registry like global variable.
The product is loaded by \Magento\Catalog\Helper\Product::initProduct. This method dispatches the event catalog_controller_product_init_after.
In the event observer RegisterCurrentProductObserver the product is set on a shared instance of the class \VinaiKopp\CurrentProductExample\Registry\CurrentProduct.
A new template block is added to the product detail page with layout XML. In the XML the block is configured to receive a view model, an instance of the class \VinaiKopp\CurrentProductExample\ViewModel\CurrentProductExampleViewModel.
The view model uses the shared Registry\CurrentProduct instance to retrieve the current product. This makes it a registry but without the downsides of the global core registry.
The template retrieves the view model from the block and renders the required product value
More detail at https://github.com/Vinai/module-current-product-example
I have created a demo extension for you.