### API Route Management with Hono (JavaScript) Source: https://developers.framer.wiki/developers/fetch/examples An example using the Hono framework to manage multiple API routes within a backend. It demonstrates setting up a basic Hono application, applying CORS middleware, and defining GET endpoints for a root path and a weather API. ```javascript import { Hono } from 'hono' import { cors } from 'hono/cors' const app = new Hono() app.use('*', cors()) app.get('/', (c) => { return c.text('Hono!') }) app.get('/weather', async (c) => { const weather = await fetch("api.weather.com").then(d => d.json()) return c.json(weather) }) export default app ``` -------------------------------- ### Create a Basic React Button Component Source: https://developers.framer.wiki/developers/components/examples This snippet shows the creation of a fundamental React button component. It serves as a starting point for more complex components and has no external dependencies. ```jsx export default function Button(props) { return
Hello
} ``` -------------------------------- ### Simple Backend Function for Fetch Requests (JavaScript) Source: https://developers.framer.wiki/developers/fetch/examples A basic backend function that returns a random greeting. It demonstrates a simple GET request handling and JSON response. This code is suitable for most JavaScript backend setups like Cloudflare Workers or Val Town. ```javascript function worker(request) { // Return a random greeting from this list const greetings = ["Hello!", "Welcome!", "Hi!", "Heya!", "Hoi!"]; const index = Math.floor(Math.random() * greetings.length); /* ...CORS Headers... */ return Response.json({ data: greetings[index] }, { headers }); } ``` -------------------------------- ### Render Page Preview using usePublishInfo Hook (React) Source: https://developers.framer.wiki/developers/plugins/site An example demonstrating how to use the `usePublishInfo` hook to get the staging URL and render a preview of the current page within an iframe. It includes a conditional message if the site has not been published yet. ```javascript const publishInfo = usePublishInfo() const stagingUrl = publishInfo?.staging?.currentPageUrl if (!stagingUrl) return "Publish your Site" return (