Description: The request object provides access to essential HTTP request information in a framework-agnostic way. This abstraction ensures your templates remain compatible across PocketBase versions.
Properties
auth
Type: core.Record | undefined
Description: The authenticated user record, if available
method
Type: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
Description: The HTTP method of the request
url
Type: URLParse<string>
Description: A parsed URL object containing query parameters and other URL components
formData()
Type: () => Record<string, any>
Description: Function that returns form data submitted with the request
body()
Type: () => Record<string, any> | string
Description: Function that returns request body as an object (if JSON) or string (if form data)
header()
Type: (name: string) => string
Description: Function that returns the value of the specified request header
cookies()
Type: (name: string) => string | undefined
Description: Function that returns the value of the specified cookie
Example Usage
Basic Request Information
<%
// Access request method
const method = request.method
// Get URL information
const path = request.url.pathname
const query = request.url.query
// Access form data
const formData = request.formData()
// Access raw body
const rawBody = request.body()
%>
Authentication Check
<%
if (request.auth) {
// User is authenticated
const userId = request.auth.id
const email = request.auth.email
} else {
// User is not authenticated
}
%>