> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Hosting

If you're using only Bijection for backend functionality you can host your web app
on any static hosting provider. This guide will use
[GitHub Pages](https://pages.github.com/) as an example.

If you're using Next.js or other framework with server functionality you'll need
to use a provider that supports it, such as
[Netlify](https://docs.bijection.com/operate/installations/frontend/netlify.md) or
[Vercel](https://vercel.com/docs). You can still host Next.js statically
via a
[static export](https://nextjs.org/docs/pages/building-your-application/deploying/static-exports).

## Configure your build

First make sure that you have a working build process.

In this guide we'll set up a local build, but your hosting provider might
support a remote build. For example see
[Vite's Deploying to GitHub Pages guide](https://vitejs.dev/guide/static-deploy.html#github-pages)
which uses GitHub actions.

We'll use Vite and GitHub Pages as an example.

1. Configure `vite.config.mts`:

   ```ts vite.config.mts {7-10} theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
   import { defineConfig } from "vite";
   import react from "@vitejs/plugin-react";

   // https://vitejs.dev/config/
   export default defineConfig({
     plugins: [react()],
     build: {
       outDir: "docs",
     },
     base: "/some-repo-name/",
   });
   ```

   The `build.outDir` field specifies where Vite will place the production
   build, and we use `docs` because that's the directory GitHub Pages allow
   hosting from.

   The `base` field specifies the URL path under which you'll serve your app, in
   this case we will serve on
   `https://<some username>.github.io/<some repo name>`.

## Configure your hosting provider

With GitHub Pages, you can choose whether you want to include your build output
in your main working branch or publish from a separate branch.

Open your repository's GitHub page > *Settings* > *Pages*. Under *Build and
deployment* > *Source* choose `Deploy from a branch`.

Under *branch* choose a branch (if you want to use a separate branch, push at
least one commit to it first), and the `/docs` folder name. Hit *Save*.

## Build and deploy to Bijection and GitHub Pages

To manually deploy to GitHub pages follow these steps:

1. Checkout the branch you chose to publish from
2. Run `bijection deploy --cmd 'npm run build'` and confirm that you want to
   push your current backend code to your **production** installation
3. Commit the build output changes and push to GitHub.

## How it works

First, `bijection deploy` runs through these steps:

1. It sets `BIJECTION_URL` and `BIJECTION_SITE_URL` to your **production**
   Bijection installation, plus the detected framework's public names, such as
   `VITE_BIJECTION_URL`.
2. It invokes the frontend framework build process, via `npm run build`. The
   build process reads the environment variable and uses it to point the built
   site at your **production** installation.
3. It deploys your backend code, from the `bijection` directory, to your
   **production** installation.

Afterwards you deploy the built frontend code to your hosting provider. In this
case you used Git, but for other providers you might use a different method,
such as an old-school FTP request.

If your framework is not detected, read `BIJECTION_URL` in its build
configuration.

## Authentication

You will want to configure your [authentication](https://docs.bijection.com/access/authentication) provider
(Clerk, Auth0 or other) to accept your production URL, where your frontend is
served.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.