I have setup gatsby project using this link. It is working correctly.
Now I know how to create route by defining the component inside the pages
pages
You can use gatsby-plugin-create-client-paths. It uses matchPath. For more info check
gatsby-plugin-create-client-paths
matchPath