Building your app for production happens through one build.
It takes the first argument as the platform, which defaults to web.
npx one build [web | ios | android]
To build for iOS for example, you would run:
npx one build ios
Building for web
When building One for web, the output will be a mostly static directory of HTML, CSS, and JavaScript. Internally, One runs a few different Vite production builds to output client, server, and API folders. This output is always in the dist directory.
Ensure your .env file has a ONE_SERVER_URL set to your production URL, like:
Terminal
ONE_SERVER_URL=https://onestack.dev
We provide a production server based on Hono with one serve that handles loaders, SSR, and API routes for you. You can choose a deploy target for that server, for now we support node and vercel. This can be chosen via your Vite configuration:
vite.config.ts
import{ one }from'one/vite'
exportdefault{
plugins:[
one({
web:{
deploy:'vercel'// defaults to node
}
})
]
}
The CLI will print instructions on how to deploy to the respective platform you choose after you run npx one build. You can choose the platform on serve instead, after a successful build:
npx one serve --platform vercel
If you are only using SPA and SSG routes and aren't using loaders, you can statically serve the results of dist/client using any server you'd like.
Building for native
We don't have an end-to-end build command yet, but One is designed to be easy to integrate into existing Expo or React Native build processes.