In a material can you detect the edges of a mesh

Does anyone know is it possible to detect in a material, if the material is near an edge?

I would like to make a material function that as something gets close to a edge it would glow. I can do it when it get closer to another object but I can’t figure how to do it for it own edges.

Thanks

Ed