How to move your React Native app Expo Router code to a new folder.

Running npx create-expo-app@latest MyProjectName -t tabs@sdk-49 makes it really easy to get started with navigation in your React Native project, however with Expo Router v1 you were locked in on their pre-installed directory structure in order to use it. Well, good news! With Expo Router v2 you’re now able to reconfigure your application’s directory structure so that you can take advantage of navigation features without compromising your desired folder structure. It may seem daunting at first, but it’s actually pretty simple and can be done in 2 steps.

Step 1 – Move Files to New Directory.

Create a new directory in your file explorer. In my case, I’m adding a folder called src to my project’s top level that will house the app, assets, components, and constants that Expo Router creates by default. Note: I’ve had occasional issues with it taking forever for files to move via VSCode, so it may be faster for you to open your project in Explorer/Finder and move them that way.

Step 2 – Update TSConfig.json Path

Once the files are moved, update your tsconfig.json file in your root directory to use the newly created directory and save. In my case I went from "./*" to "./src/*" and that was it, all done!

Note: if you’re going to keep some files/directories outside of your new folder you will just need to be sure to update those paths manually in your files.
Additionally, if moving your assets folder, you will need to update your app.json file in a few spots to include the new path.

That’s it. I hope it helps!

4 Responses to “How to move your React Native app Expo Router code to a new folder.”

  1. Aimee H

    Hi would you mind letting me know which hosting company you’re working with? I’ve loaded your blog in 3 completely different browsers and I must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a fair price? Thanks a lot, I appreciate it!

  2. Reinaldo Arnone

    Awesome blog! Do you have any suggestions for aspiring writers? I’m planning to start my own website soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally confused .. Any tips? Thanks a lot!

  3. Bart Cierley

    Good day! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Cheers!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>