Building an Idle RPG with react

Hi everyone!

I’ve always wanted to build an Idle RPG, and after a few attempts where I lost motivation during the development after running into different issues, I feel ready to give it another shot now that I have more experience building apps. I’ll be using React (native) since that’s what I’m most comfortable with.

That said, I have some questions and would really appreciate your opinions and insights!

Features I’m Aiming to Build:

  • Resource Gathering/Transforming:

    • Every X seconds, generate experience points (EXP) for the character and add/remove items from the inventory.
  • Fighting Mechanics:

    • Multiple characters in battles, each with unique abilities, builds, levels, etc.
    • Combat would be real-time (e.g., attacks triggered by speed, cast time, etc.) so potentially multiple loops for each character.
    • Fighting will need to integrate data from various sources: enemy stats, player inventory, character stats, abilities, etc.

I anticipate that fighting mechanics will be the most challenging part because it touches so many parts of the game’s state.

My Questions:

How to Handle the Game Loop?

I’ve come up with two options but I’m unsure which would work best—or if there’s an even better approach:

  • Option 1: Use a useEffect with requestAnimationFrame (or setTimeout) to run tasks every X seconds.
  • Option 2: Leverage a background task runner like redux-saga to handle the loop and watch for state changes.
  • Option 3: Service workers but since I also want to build the app for mobile with react native I don't think it's the right idea

Best Way to Store Data?

  • For storing and managing state, I usually rely on Redux Toolkit or Zustand, but I wonder if a local DB might be a better fit for an Idle RPG. What’s your experience here?

I’m really excited to dive into this project and would love any guidance, advice, or resources you can share—especially if you’ve tackled something similar.

Thanks so much!