Type-Safe Routing with JSDoc
Define routes using simple JSDoc annotations. Pastoria generates type-safe routing code automatically, giving you full IDE autocomplete and type checking without manual configuration.
/**
* @route /users/:userId
* @param userId string
*/
export const entrypoint: EntryPoint = {
root: JSResource.fromModuleId('m#user_profile'),
getPreloadProps({params, schema}) {
const {userId} = schema.parse(params);
return {
queries: {
userQueryRef: {
parameters: UserProfileQueryParameters,
variables: {userId},
},
},
};
},
};
GraphQL with React Relay
Built on React Relay for efficient data fetching with automatic query optimization, persisted queries, and seamless server-side rendering. Queries are preloaded on the server and hydrated on the client.
export const UserProfile: EntryPointComponent = ({queries}) => {
const data = usePreloadedQuery(
graphql`
query UserProfileQuery($userId: ID!) @preloadable {
user(id: $userId) {
name
email
...UserAvatar_user
}
}
`,
queries.userQueryRef,
);
return <UserCard user={data.user} />;
};
SSR & Code Generation
Server-side rendering out of the box with automatic code splitting and lazy loading. Run pastoria gen to generate your router, then pastoria dev to start developing with hot module replacement.
# Generate type-safe router
$ pastoria gen
# Start dev server with HMR
$ pastoria dev
# Build for production
$ pastoria build
# Deploy with the standalone server
$ pastoria-server