Rev surge in Ford Ranger 2003

Got a problem. The revs surge from low idle to high (about 1000 rpm) every few seconds, but only when the truck is in gear,
and the AC is on. Please tell me what it could be and how expensive it might be. Also is it something I could fix myself? I have been driving
with out the AC for a while but going into summer I need it on.

some cars will raise the ideal whrn the a/c comp. clutch engages so this mioght be normal.

While it is true that most cars have a circuit to raise idle speed when the A/C is engaged, the surging certainly is not normal.

Not to be snarky, but my opinion is if you have to ask if you can fix it yourself, you usually can’t,
I would bring it to a local shop if I were you.