
Quick Start
You probably confused withindex.tsx
and app/_layout.tsx
.
Understanding URLs in Expo Router
When working with Expo Router, it’s important to understand how file paths are converted to URLs. Here’s how it works:URL Conversion Rules
1
Get the File Path
Right click on your file and choose “copy relative path”. You’ll see something like:
2
Remove app Directory
Remove ‘app’ since it’s not part of the URL:
3
Remove Group Indicators
Remove any routes with () since they’re just used for grouping and not part of the URL:
4
Replace index
Replace any filenames called ‘index’ with / because that’s not part of the URL:
Examples
Here are some common examples of how file paths map to URLs:- app/(tabs)/(home)/index.tsx -> /
- app/(tabs)/(home)/details.tsx -> /details
- app/(tabs)/carts/index.tsx -> /carts
- app/(tabs)/carts/checkout.tsx -> /carts/checkout
You can’t have two files end up with the same URL. For example, having both
(home)/index
and (carts)/index
won’t work because they would both resolve to the same URL, which is not possible.(home)/index
and (carts)/index
won’t work because they would both resolve to the same URL, which is not possible.
Thats it. You are done. Now let’s try to create a new page and test it!