Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1.82 KB

routing.md

File metadata and controls

37 lines (22 loc) · 1.82 KB

Routing

This document provides an overview of the routing mechanism in the Singularity framework. It explains how routes are automatically mapped to files and how to create new routes.

Table of Contents

Automatic Route Mapping

In the Singularity framework, routes are automatically mapped to files in the client directory. This helps to prevent relative and absolute paths hell.

  • filename.ext inside the client folder will be automatically served at /filename.ext.
  • filename.jsx inside the client folder will be automatically rendered and served at /filename.
  • filename/filename.jsx inside the client folder will be automatically rendered and served at /filename.

This is to prevent index hell, where every file in your project is called index. The framework enforces you to either have a filename.jsx in the client folder or filename/filename.jsx. Any index.jsx apart from the main client/index.jsx will be ignored.

Creating New Routes

To create a new route, simply add a new file in the client directory with the desired route name. For example:

  • To create a route for /about, add a file named about.jsx in the client directory.
  • To create a route for /contact, add a file named contact.jsx in the client directory.

The framework will automatically map these files to the corresponding routes.

Dynamic Routes

Dynamic routes are not yet supported in the Singularity framework. However, you can use normal API fetch for data fetching.

Nested Routes

Nested routes are not yet supported in the Singularity framework. However, you can create nested directories in the client folder to organize your files better.