The CLI will guide you through the process of bootstrapping one of our starter templates.
If this is your first One app, we recommend taking this route, as you can choose between bare-bones example all the way up to a full stack with a user system and authentication. We will be launching more starters as the project matures.
One expects your file system routes to be placed in an app directory.
app/_layout.tsx serves as the top-level wrapper for all routes, ideal for:
Consistent page structure
Global styles or themes
Persistent navigation
App-wide state management
One uses the <Slot /> component to indicate where child components should render, allowing for nested layouts and fine-grained control over your UI structure.
Let's create a root layout app/_layout.tsx:
app/_layout.tsx
import{ Slot }from'one'
exportdefaultfunctionLayout(){
return<Slot/>
}
And then create a simple index page app/index.tsx:
If the port isn't taken, you should be able to load http://localhost:8081 and to see your website (use --port to change the port).
On native, you can use an Expo Go development app and load your app with exp://0.0.0.0:8081. Press the key combination q, r in your terminal which is running the dev server, and scan the QR code with your iPhone's camera if your computer and iPhone are connected to the same WiFi network.
Note that for web-only projects you don't need react-native, and further note that if you want something that has a much broader styling featureset and much lighter bundle-size on web, you can use Tamagui, which has no dependency on React Native.