Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: add example on Remix + Payload Local API #10171

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Dec 25, 2024

Adds example on using the Local API (both fetching data and modifying data) with Remix.

Screen.Recording.2024-12-25.at.17.54.01.mov

This is achieved through the monorepo:

website/
payload/

You can import the Payload config and types like this:

import type { ActionFunctionArgs, MetaFunction } from '@remix-run/node'
import { Form, useLoaderData } from '@remix-run/react'
import { getPayload, PaginatedDocs } from 'payload'
import { config, Post } from 'payload-app'
export const meta: MetaFunction = () => {
return [{ title: 'New Remix App' }, { name: 'description', content: 'Welcome to Remix!' }]
}
export const loader = async () => {
const payload = await getPayload({ config })
const posts = await payload.find({ collection: 'posts', sort: 'createdAt' })
return Response.json(posts)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant