I guess a sun star is rather self explanatory just by the name as such. But it does not necessarily come from a sun – it can be any bright light source like a lamppost at night or your smartphone, as this low key image illustrates:Sun star, here the light comes from an iPhone!
To produce a sun star you obviously need a bright light source like the sun, a spot, a lamppost or the like. And then you need stop down the lens, i.e. go to a high f-stop number – this will help produce the sun star. If then in addition partly block the bright light source so it is a very small spot that produces the bright light, then that further helps the sun star to appear.
I usually shoot in aperture priority mode and that allows me to set the aperture and let the camera calculate the shutter speed to get a correct exposure. In order to avoid too slow shutter speeds, I may increase the ISO from base ISO to say 800 or 1200 to secure that camera shake and motion blur is prevented. For most cameras you can easily set the ISO to values between 800 and 1200 without affecting the image quality.
The number of peaks in the sun star is a function of the number of aperture blades in your lens, so that the number of peaks is double the number of aperture blades. Your blades can also be shaped a bit differently: straight blades in my opinion gives the most beautiful sun stars, whereas rounded blades make then less well defined. But this is all personal preference.
A sun star can be used as a tool to emphasise a scene. In the example above the sun star underlines the beautiful quiet morning with the sun rays seeping through the trees to light up parts of the grass. You will also notice a bit of lens flare top right of the sun star – you can minimize this in general using a lens hood, or if you shoot into the sun, try to point directly into the sun so the lens flare is put on top of the sun itself.
Video link
Related reading
Which Nikon lens type should you buy?