
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-auto-route
Advanced tools
React Native Auto Route is a file-based router for React Native CLI. Built on top of Expo Router and React Navigation
Check out our documentation page for more information

yarn add react-native-auto-route
yarn add react-native-screens react-native-safe-area-context
If you're on a Mac and developing for iOS, you need to install the pods (via Cocoapods) to complete the linking.
npx pod-install ios
react-native-screens package requires one additional configuration step to properly work on Android devices. Edit MainActivity.kt or MainActivity.java file which is located under android/app/src/main/java/<your package name>/.
Add the highlighted code to the body of MainActivity class:
import android.os.Bundle;
class MainActivity: ReactActivity() {
// ...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null)
}
// ...
}
Or
import android.os.Bundle;
public class MainActivity extends ReactActivity {
// ...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
}
// ...
}
Add react-native-auto-route/plugin plugin to your babel.config.js
module.exports = {
presets: [
... // don't add it here :)
],
plugins: [
...
['react-native-auto-route/plugin'],
],
};
Add unstable_allowRequireContext transformer option to your metro.config.js
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
unstable_allowRequireContext: true,
},
};
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
yarn start --reset-cache
import RouterRoot from 'react-native-auto-route';
<RouterRoot />
When a file is created in the screens directory (default is: app), it will be automatically added to the routes. For example, the following files will create the following routes:
app/index.tsx matches /app/home.tsx matches /homeapp/settings/index.tsx matches /settingsapp/[user].tsx matches dynamic paths like /userId1 or /userId2app/(group)/tab1.tsx matches /tab1Supported extensions:
.tsx,.ts,.jsx,.js
import React from 'react';
import {Text, View} from 'react-native';
export default function Home() {
return (
<View>
<Text>Home</Text>
</View>
);
}
You can create dynamic routes by using square brackets in the file name. For example, the following files will create the following routes:
app/[user].tsx matches dynamic paths like /userId1app/[user]/[post].tsx matches dynamic paths like /userId1/postId1app/detail/[postId].tsx matches dynamic paths like /detail/postId1app/detail/[...postId].tsx matches dynamic paths like /detail/postId1/editRoutes with higher specificity will be matched before a dynamic route. For example, /detail/post will match detail/post.tsx before detail/[id].tsx.
Multiple slugs can be matched in a single route by using the rest syntax (...). For example, app/detail/[...postId].tsx matches /detail/postId1/edit.
You can get params from the route by using the useParams hook.
import React from 'react';
import {Text, View} from 'react-native';
export default function UserPost() {
const params = useParams();
return (
<View>
<Text>Detail: {params.user} - {params.post}</Text>
</View>
);
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library
FAQs
file-based router for React Native CLI
The npm package react-native-auto-route receives a total of 6 weekly downloads. As such, react-native-auto-route popularity was classified as not popular.
We found that react-native-auto-route demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.