How I can implement Table of contents section for blogs in next js using strapi?

If you are using the new Blocks editor, it saves content as a JSON object. You can write a little recursive function to walk that json and generate a TOC according to your needs