Route aliases: Serve same component at multiple URL paths
Gourav Aggarwal
How can we serve the same route component under multiple URL paths in Expo Router without duplicating route files?
For example, I want both /path/123 and /with/prefix/path/123 to render the same Path component. Currently, it seems the only way to achieve this is by duplicating the route files for each path like shown below -
src/app/
├── (app)/
│ ├── path/
│ │ └── [id].tsx # Standard route: /path/123
│ │
│ └── with/
│ └── prefix/
│ └── path/
│ └── [id].tsx # Prefixed route: /with/prefix/path/123
│
└── components/
└── PathComponent.tsx # Shared component used by both routes
Can we introduce aliasing in expo to avoid the duplication of files?