# Frontends

Source: https://docs.anetos.dev/main/guides/frontends/

- [Bundle JavaScript and CSS with Vite](https://docs.anetos.dev/main/guides/vite/index.md): Add a frontend that [Vite](https://vite.dev) builds: TypeScript or JavaScript modules, CSS, and npm packages. Its pages update as you edit them in development, and its build is embedded in the app's binary for production.
- [Build pages in React](https://docs.anetos.dev/main/guides/react/index.md): In a project of the react stack, the Go side is the web stack's: routes, handlers, sessions, validation, translations and logins stay in Go. The pages are React components in TypeScript, which Inertia's client renders in the browser with the props a handler sends. Each page's props are a Go struct, and the TypeScript types the components use are generated from it, so the type check catches a renamed field or route before the browser does.
- [Build pages in Svelte](https://docs.anetos.dev/main/guides/svelte/index.md): In a project of the svelte stack, the Go side is the web stack's: routes, handlers, sessions, validation, translations and logins stay in Go. The pages are Svelte 5 components in TypeScript, which Inertia's client renders in the browser with the props a handler sends. Each page's props are a Go struct, and the TypeScript types the components use are generated from it, so the type check catches a renamed field or route before the browser does.
- [Build pages in Vue](https://docs.anetos.dev/main/guides/vue/index.md): In a project of the vue stack, the Go side is the web stack's: routes, handlers, sessions, validation, translations and logins stay in Go. The pages are Vue single-file components in TypeScript, which Inertia's client renders in the browser with the props a handler sends. Each page's props are a Go struct, and the TypeScript types the components use are generated from it, so the type check catches a renamed field or route before the browser does.
- [Pages in Vue, React or Svelte with Inertia](https://docs.anetos.dev/main/guides/inertia/index.md): Write the pages as Vue, React or Svelte components while the routes, handlers, sessions, validation and redirects stay in Go. A handler renders a page component with its props, which [Inertia](https://inertiajs.com)'s client shows; links and forms then visit the server without reloading the page. There is no JSON API to design: the props are the page's data.
- [Move htmx pages to Inertia](https://docs.anetos.dev/main/guides/migrate-htmx-to-inertia/index.md): A project of the web stack renders its pages with templ and htmx. The react, svelte and vue stacks keep the same Go side (routes, handlers, sessions, validation, logins) and render the pages as components with Inertia. Moving from one to the other changes the views, not the app: the handlers send props instead of rendering templ components. This guide moves a project page by page, with both kinds of pages working side by side until the last one moves.
- [Generate TypeScript types for the frontend](https://docs.anetos.dev/main/guides/typescript/index.md): Give the frontend the types of the app's Go code: the inputs and results of the API's handlers, with a client that calls them, and the props of the Inertia pages. The types are generated from the Go types, so when a field changes in Go, TypeScript's type checks find what to change in the frontend.
- [Build a single-page app](https://docs.anetos.dev/main/guides/spa/index.md): Give an API project a single-page app (SPA): a frontend in React, Svelte, Vue, or plain TypeScript or JavaScript, which Vite builds, the app's binary embeds and serves at `/`, and which calls the API with a client generated from the handlers' Go types. In development, Vite serves it with hot reload and forwards `/api` to the app; the SPA logs in with a session cookie.
- [Log in from your SPA with a session cookie](https://docs.anetos.dev/main/guides/spa-login/index.md): An API project's accounts ([Add accounts to an API](https://docs.anetos.dev/main/guides/api-accounts/index.md)) log in with tokens. Your own single-page app, built with React, Svelte, Vue or anything else, can log in with a session cookie instead: the browser keeps it out of reach of the page's scripts, so a script injected into the page can't steal the login, as it could a token kept in JavaScript. Tokens stay for everything else: mobile apps, programs, other people's sites.
- [Move htmx pages to an API and an SPA](https://docs.anetos.dev/main/guides/migrate-htmx-to-spa/index.md): A project of the web stack renders its pages on the server. With a single-page app, the browser renders them, and the server answers JSON: the handlers return data instead of pages, validation errors come back as a `422` answer instead of a redirect, and the SPA has its own router, text and forms. Since every page and most handlers change, this guide builds the API as a new project of the api stack beside the old one, on the same database, adds the SPA to it, and switches over when it's ready. The old app keeps serving your users until then.
