Flight
Boston Logan International Airport (BOS) is the closest major airport to Cape Cod offering direct flights from most U.S. locations. Depending on traffic, it is an approximately 1.5-2 hour drive to Harwich/Chatham. It is possible to fly into Cape Cod Gateway Airport. Usually those flights stop in at Boston Logan Airport & end up costing more than renting a car for 1-2 days or transferring to take a Bus (see below)
Rental Car
Free shuttle from the Airport to Boston Logan Car Rental (multiple options available) Keep in mind that getting on and off the Cape on Fridays and Sundays can often take longer due to traffic. - Boston: 1:30-2 hours with moderate traffic. Upwards of 3 hours during rush hour. - NYC: 4:30-5 hours with moderate traffic. Upwards of 6 hours during rush hour.
Travel Note
Plymouth Brockton Bus operates from Boston Logan and Boston’s South Station with drop off points on Cape Cod in Hyannis and Barnstable Park & Ride. Make sure to select; Hyannis/South Shore to Boston/Logan Airport Bus Schedule (link below to schedule/timing of buses) https://www.p-b.com/schedules/hyn-bsn-lgn-webschedule