JSFiddle - React, Tailwind, and code Playground

HTML

<svg class='my-svg' width=200 height=200>
  <rect width=100 height=100 fill='red'></rect>
</svg>

JavaScript

import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm"

const zoomBehavior = d3.zoom()
	.on('zoom', function (event) {
    const pointer = d3.pointer(event, this)
  })
  
const mySvg = d3.select('.my-svg').call(zoomBehavior)

mySvg.call(zoomBehavior.scaleTo, 1)