0xTanzim / 0xTanzim/nextRush

Support for folder-based routing similar to Next.js

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
4
Forks
0
Avg merge
6m
Merged PRs (30d)
1

Description

## Feature Request: Folder-based Route Support (like Next.js)

### Overview
Implement folder-based routing in `nextRush`, similar to how Next.js handles API routes. In Next.js, the structure of the `pages/api` folder directly maps to API endpoints. For example:

- `pages/api/user.js` → `/api/user`
- `pages/api/posts/index.js` → `/api/posts`
- `pages/api/posts/[id].js` → `/api/posts/:id`

### Proposal
- Add support for folder-based routing so that the file and folder structure under a designated directory (such as `routes/` or `api/`) automatically maps to endpoint paths.
- Allow dynamic segments and catch-all routes (e.g., `[id].js`, `[...slug].js`) as in Next.js.
- Example structure:

```
routes/
├── user.js // maps to /user
├── posts/
│ ├── index.js // maps to /posts
│ ├── [id].js // maps to /posts/:id
│ └── [...slug].js // maps to /posts/*
```

### Additional Details
- Include a configuration setting in `nextRush` to enable/disable folder-based routing.
- Setting could be in the main config file, e.g., `folderRouting: true | false`.
- When disabled, fallback to manual route definitions.

### Benefits
- Easier, more maintainable routing configuration.
- Consistency with Next.js and developer expectations.

### References
- [Next.js API Routes Documentation](https://nextjs.org/docs/pages/building-your-application/routing/api-routes)

---
**Request:** Add folder-based route support with a configuration toggle in `nextRush`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.