How Routing Works
Name a folder or file after a route, and Rogen puts it where the route points
Updated
Your config's routes name the places your code can go in the game:
{
"routes": {
"Server": "ServerScriptService",
"Client": "StarterPlayer/StarterPlayerScripts",
"Shared": "ReplicatedStorage/Shared",
"*": "ReplicatedStorage/Shared"
}
}A route's name in a file's path sends the file there. A Server/ folder sends everything inside it, and @Client at the end of a name sends one file:
- src
- Shop
- Server
- ShopService.luau
- Shared
- Prices.luau
- ShopUi@Client.luau
- ReplicatedStorage
- Shared
- Shop
- Prices
- ServerScriptService
- Shop
- ShopService
- StarterPlayer
- StarterPlayerScripts
- Shop
- ShopUi
Everything else in the path stays, so Shop shows up under each service. The route's name must be spelled exactly as its key: a server/ folder or Save@Sever.luau under a Server route is an error, so a typo never sends server code somewhere else.
Each way to route has its own page: Routing Folders, Routing by Name and Routing by Pattern. Skipping Folders shows how to leave a folder out of the game.
Files Without a Route
The * route takes every file that no other route matches, so src/Shop/Prices.luau lands in ReplicatedStorage/Shared/Shop. A pattern route such as *.tsx takes a file by its name before * does. rogen init writes it. Without *, Rogen leaves such a file out and warns about it, so a server file that forgets its route never reaches clients. That suits a project where every file names its side.
The Outermost Route Wins
A route inside another route is an ordinary folder. Server code under Shared/ ships to every client, and Rogen warns about it:
- src
- Shared
- Server
- Datastore.luau
- ReplicatedStorage
- Shared
- Server
- Datastore
Check Where a File Lands
rogen where prints where a file lands in the game, and the require that reaches it:
$ rogen where src/Shop/Server/ShopService.luau
src/Shop/Server/ShopService.luau -> ServerScriptService/Shop/ShopService · route Server (folder)
require(game:GetService("ServerScriptService").Shop.ShopService)