So i checked the few available solutions. But in my case when I hold the wheel and shake it sideways it is not wobbling it is firm. But when I ride I can see the tyre wobbling and it looks like the sprocket is moving, it is like the sprocket is not firm on the axel? not sure what the problem could be.
If the rim is moving side-to-side when you ride your wheel is out of true and needs truing (i.e. the spoke tension has to be adjusted). It’s especially noticeable with rim brakes because the rim will start to rub on the brake pads during some parts of its rotation.
If only the tire is wobbling: Some wobble can be normal, if it’s worse the tire is probably not well seated in the rim. You can try inflating it to maximum pressure (or even slightly more) and see if it “pops” into the correct position. Release air until you’ve reached your desired riding pressure afterwards.
If the cassette or sprocket looks like it’s wobbling: Sometimes it just looks that way, but make sure it’s tightened (cassettes need up to 40Nm of torque, which is quite a lot) correctly.