While fresh basil and spinach are preferred for the best flavor, you can use frozen basil or spinach in a pinch. Just make sure to thaw and drain them before adding them to your pesto mixture.