Single-particle imaging using laser-illuminated widefield epi-fluorescence microscopy is a powerful tool to investigate molecular processes in vivo. Performing high-quality single-molecule imaging in such biological systems, however, remains a challenge due to difficulties in controlling the number of fluorescing molecules, photobleaching, and the autofluorescence background. Here, we show that by exciting only a small, 5-15 μm wide region in chemosensory neurons in live C. elegans, we can significantly improve the duration and quality of single-molecule imaging. Small-window illumination microscopy (SWIM) allows long-duration single-particle imaging since fluorescently labelled proteins are only excited upon entering the small excited area, limiting their photobleaching. Remarkably, we also find that using a small excitation window significantly improves the signal-to-background ratio of individual particles. With the help of theoretical calculations, we explain that the improved signal-to-background ratio is due to reduced background, mostly caused by out-of-focus autofluorescence. We demonstrate the potential of this approach by studying the dendritic transport of a ciliary calcium channel protein, OCR-2, in the chemosensory neurons of C. elegans. We reveal that OCR-2-associated vesicles are continuously transported back and forth along the length of the dendrite and can switch between directed and diffusive states. Furthermore, we perform single-particle tracking of OCR-2-associated vesicles to quantitatively characterize the transport dynamics. SWIM can be readily applied to other in vivo systems where intracellular transport or cytoskeletal dynamics occur in elongated protrusions, such as axons, dendrites, cilia, microvilli and extensions of fibroblasts.