Pages
Declare a Next.js page in your Mosaic module
Last updated
Was this helpful?
Declare a Next.js page in your Mosaic module
Last updated
Was this helpful?
Next.js has a limitation on the project structure - all of the pages should be located in the pages
directory. Mosaic removes this limitation, thus allowing for a modular project structure. Each Mosaic module is able to register its own pages, which will be taken into account during the build time.
In order to declare a Next.js page, some preparations are necessary. This will work only in Next.js powered by Mosaic, launched with package @tilework/mosaic-nextjs-scripts
First of all, an extension module must be . You will implement your page there.
For the development purposes, it's recommended to have the under-development extension module into your project.
The following page types are available:
: server
: static-no-data
: static-with-data
In order to have an additional page in a Mosaic-powered Next.js application, the first step is to register this page in order to let the Mosaic build system know about the page. It should be done in the following way.
Instead of the server
you may use one of the described above.
A template page, similar to the following, will be generated after the actions above. For different page types, different templates will be generated. This will cause additional to be available for .
Add functionality and contents to it with !
The code example shown below explains, how to implement the page declared above. It uses our plugin system, if you are not yet familiar to it - get acknowledged in .