Grid material that extends with mesh?
This will work for mesh with planar surfaces aligned to the world axis.
That can be this kind of settings, based on world coordinates as input:

It adds the object location to object coordinates so that the result is sensible to the mesh location. Then, it takes a cross product with the normal, in order to avoid limit values to appear when calculating the grid (you'll can test the difference, using it or not).
The grid itself is just a comparison to some value, of the fraction part of the scaled coordinates. More precisely, if the value is around 0.5 (again to avoid limit cases we may encounter if comparing to 0 or 1).


Edit

If you want the grid to be stable from the object position, change the input like that (the object location is substrated from the surface location in world coordinates):

Is you want the grid to be aligned to the object (if its origin is in a corner), change the node group shifting it 0.5/scale (see below on left).
And to avoid limit cases, keep only one positive test (below on right).

Updated blend file: