10-speed cassettes are compatible with the 8-speed hubs, and the splines of 10-speed cassettes are compatible with the 8-speed hubs, all the Shimano 8-speed hubs are compatible with the 7,8,9, and 10-speed cassettes. but if the cassette or freehub body is campy, then it is not possible to install campy 10-speed cassettes with the campy 8-speed hub. but all the Shimano 10-speed cassettes and 8-speed hubs are compatible with each other, and also Shimano and campy cassettes and freehubs are non-compatible with each other. and also check the lining of the chain, if the lining is not accurate then you have to insert small compatible hub-sized washers in the axle which will give the chain an accurate lining from the chain ring towards the sprockets of the cassette.
You also need new compatible 10-speed shifters with the 10-speed cassette, because 8-speed shifters have a different cable pull ratio than the 10-speed shifters, and the cable pull ratio can easily be accurate and maintained by tightening or loosening the limit screws or B screws of the rear derailleur, you also need to adjust the barrel adjuster of new 10-speed shifters in this setup. The 8-speed hub chain is also non-compatible with the 10-speed cassette. you have to buy a new compatible chain for a 10-speed cassette, side plates of the chain and the quick links of 8 and 10-sped chains have different widths, so you have to find another old used compatible chain for this setup.
The value of the cog pitch and cog widths of both of these cassettes are different, due to which both of the cassettes require different chains, and also the chain requires their own compatible derailleurs so that the chain would easily roll through the derailleur cage and small jockey wheels and pulleys of the derailleur smoothly. and if your bike has tri-spoke wheels, then this setup will also not work, you have to look for another compatible wheelset for this setup.8-speed hubs are old and more traditional discoveries than new modern 10 and 11-speed hubs, parts, and tools of 8-speed hubs are rare nowadays and new modern and expensive derailleurs and cassettes are not compatible with these hubs.
If the 10-speed cassette is of SRAM brand then it does not need any spacers for the 8-speed hub, but the Shimano 10-speed cassettes require small 1mm sized spacers for this setup to make the cassette compatible with the freehub. but it is not for all brands of cassettes. new modern and expensive cassettes are larger and bigger in size, for these cassettes it is not necessary to install spacers. Campagnolo 10-speed cassettes with 8-speed hubs are not compatible with each other, due to the different sizes of splines in cassette design. cog pitch is the ratio of the cable pull and cable pull ratio, the value of the cog pitch is similar to the same for SRAM and Shimano brands, but the value is different for the Campagnolo cassettes and shifters.
The chain and cassette would not cause any irritating and rubbing noises when the chain moves through the sprockets, derailleur, and the chin ring of the crankset, and also if you are looking for a new 8-speed cassette for an 8-speed hub or 10-speed cassette for the 10-speed hub, then this setup will save you bucks spending on new expensive bike parts. and also 10-speed cassette has more gears than an 8-speed cassette, greater number of gears also have a lot of advantage especially when you are climbing uphills or cross-country trails, your bike will easily boost, and pedal striking also will increase with more much of gears. It is a cheap setup and you cannot have to buy extra bike parts.
You can check the lining of the chain by shifting the gears within the cogs and sprockets of the cassette, if the gears are not working properly then you have to adjust the lining of the rear cassette and the crankset of the bottom brackets, both of these parts require small compatible sized sp[acers and wavy washers for the correct lining of the chain.
Road And Mountain biking:
You can easily adapt this setup for both mountain and road biking, the setup is compatible and can make your ride smooth and comfortable to void buying new parts.