Getting started

Create a project, run the dev server, and open the page. That is the whole setup.

Create a project

terminal
npx @veyra-labs/velz create my-site --template marketing
cd my-site
npm install
npm run dev

Three templates ship with the framework: blank, marketing and docs. Every template already follows the design rules, so you start from a finished page instead of an empty file. Each shell includes Nav, so the product name rolls to by Veyra out of the box.

Add a page

Pages are files. Create src/pages/about.tsx and it is live at /about.

about.tsx
import { Head } from '@veyra-labs/velz'
import { Container, Heading, Lead, Section } from '@veyra-labs/velz/ui'

export default function About() {
  return (
    <>
      <Head title="About" description="Who we are and why this exists." />
      <Section>
        <Container>
          <Heading level={1} size="display">About</Heading>
          <Lead>Say the true thing, briefly.</Lead>
        </Container>
      </Section>
    </>
  )
}

Add data

A page can export a load function. It runs on the server before the page renders, and whatever it returns arrives as props.data.

post.tsx
export async function load({ params }) {
  const post = await getPost(params.slug)
  return { post }
}

export default function Post({ data }) {
  return <h1>{data.post.title}</h1>
}

Add an API route

contact.ts
// src/api/contact.ts
export const POST = async (request) => {
  const body = await request.json()
  return Response.json({ received: body.email })
}

Build and ship

terminal
npm run build    # dist/client and dist/server
npm run preview  # serve the production build locally