Skip to content

Commit ae559be

Browse files
committed
feat: add File based router support with Expo Router
1 parent 562b5c4 commit ae559be

12 files changed

+4961
-3530
lines changed

App.tsx

-3
This file was deleted.

Main.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'expo-router/entry';

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Developer experience first:
1414
- ⚛️ [React Native](https://reactnative.dev) for building native apps using React
1515
- 🔥 Type checking [TypeScript](https://www.typescriptlang.org)
1616
- 💎 Integrate with [NativeWind](https://www.nativewind.dev), Tailwind CSS for React Native
17+
- 📁 File-based routing with Expo Router
1718
- 📏 Linter with [ESLint](https://eslint.org)
1819
- 💖 Code Formatter with [Prettier](https://prettier.io)
1920
- 🦊 Husky for Git Hooks

app.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"orientation": "portrait",
77
"icon": "./assets/icon.png",
88
"userInterfaceStyle": "light",
9+
"scheme": "myapp",
910
"splash": {
1011
"image": "./assets/splash.png",
1112
"resizeMode": "contain",
@@ -24,7 +25,8 @@
2425
"package": "com.anonymous.reactnativeboilerplate"
2526
},
2627
"web": {
27-
"favicon": "./assets/favicon.png"
28+
"favicon": "./assets/favicon.png",
29+
"bundler": "metro"
2830
},
2931
"plugins": ["@config-plugins/detox"]
3032
}

app/_layout.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { Stack } from 'expo-router';
2+
3+
export default function Layout() {
4+
return <Stack />;
5+
}

app/index.tsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Stack } from 'expo-router';
2+
3+
import { Welcome } from '@/templates/Welcome';
4+
5+
const Home = () => (
6+
<>
7+
<Stack.Screen
8+
options={{
9+
title: 'My home',
10+
}}
11+
/>
12+
<Welcome />
13+
</>
14+
);
15+
16+
export default Home;

babel.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = (api) => {
1313
},
1414
},
1515
],
16+
require.resolve('expo-router/babel'),
1617
],
1718
};
1819
};

package-lock.json

+4,900-3,497
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "react-native-boilerplate",
33
"version": "1.0.0",
4+
"main": "Main.tsx",
45
"scripts": {
56
"start": "expo start --dev-client",
6-
"android": "expo run:android",
7-
"ios": "expo run:ios",
87
"dev:android": "expo start --android",
98
"dev:ios": "expo start --ios",
109
"web": "expo start --web",
10+
"build:android": "expo run:android",
11+
"build:ios": "expo run:ios",
1112
"clean": "rimraf .expo android coverage ios index.js",
1213
"lint": "eslint .",
1314
"format": "eslint --fix . && prettier '**/*.{json,yaml}' --write --ignore-path .gitignore",
@@ -23,27 +24,33 @@
2324
"prepare": "husky install"
2425
},
2526
"dependencies": {
26-
"expo": "~48.0.11",
27-
"expo-splash-screen": "~0.18.1",
27+
"expo": "~48.0.16",
28+
"expo-constants": "^14.2.1",
29+
"expo-linking": "^4.0.1",
30+
"expo-router": "^1.5.3",
31+
"expo-splash-screen": "~0.18.2",
2832
"expo-status-bar": "~1.4.4",
2933
"nativewind": "^2.0.11",
3034
"react": "18.2.0",
31-
"react-native": "0.71.6"
35+
"react-native": "0.71.7",
36+
"react-native-safe-area-context": "4.5.0",
37+
"react-native-screens": "^3.20.0",
38+
"react-native-web": "~0.18.10"
3239
},
3340
"devDependencies": {
34-
"@babel/core": "^7.21.4",
41+
"@babel/core": "^7.21.8",
3542
"@config-plugins/detox": "^5.0.1",
3643
"@testing-library/jest-native": "^5.4.2",
37-
"@testing-library/react-native": "^12.0.1",
44+
"@testing-library/react-native": "^12.1.2",
3845
"@types/detox": "^18.1.0",
3946
"@types/jest": "^29.5.1",
40-
"@types/react": "^18.0.38",
47+
"@types/react": "~18.0.27",
4148
"@types/react-native": "^0.71.6",
42-
"@typescript-eslint/eslint-plugin": "^5.59.1",
43-
"@typescript-eslint/parser": "^5.59.1",
44-
"detox": "^20.7.0",
45-
"eas-cli": "^3.10.0",
46-
"eslint": "^8.39.0",
49+
"@typescript-eslint/eslint-plugin": "^5.59.5",
50+
"@typescript-eslint/parser": "^5.59.5",
51+
"detox": "^20.8.0",
52+
"eas-cli": "^3.12.0",
53+
"eslint": "^8.40.0",
4754
"eslint-config-airbnb": "^19.0.4",
4855
"eslint-config-airbnb-typescript": "^17.0.0",
4956
"eslint-config-prettier": "^8.8.0",
@@ -61,11 +68,11 @@
6168
"husky": "^8.0.3",
6269
"jest": "^29.5.0",
6370
"jest-expo": "^48.0.2",
64-
"lint-staged": "^13.2.1",
71+
"lint-staged": "^13.2.2",
6572
"npm-run-all": "^4.1.5",
6673
"prettier": "^2.8.8",
6774
"rimraf": "^5.0.0",
68-
"tailwindcss": "^3.3.1",
75+
"tailwindcss": "^3.3.2",
6976
"typescript": "^4.9.5"
7077
}
7178
}

src/Main.tsx

-11
This file was deleted.

src/Main.test.tsx src/templates/Welcome.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { render, screen } from '@testing-library/react-native';
22

3-
import { Main } from './Main';
3+
import { Welcome } from './Welcome';
44

55
describe('App component', () => {
66
describe('Render method', () => {
77
it('should render the default text', () => {
8-
render(<Main />);
8+
render(<Welcome />);
99

10-
const text = screen.queryByText(/Open up App.js/);
10+
const text = screen.queryByText(/Open up App\//);
1111
expect(text).toBeVisible();
1212
});
1313
});

src/templates/Welcome.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Text, View } from 'react-native';
2+
3+
const Welcome = () => (
4+
<View className="flex-1 items-center justify-center">
5+
<Text>Open up App/ to start working on your app!</Text>
6+
</View>
7+
);
8+
9+
export { Welcome };

0 commit comments

Comments
 (0)