Keystatic and static site generation #826
-
A total noob question: The keystatic+astro docs mention that keystatic needs the astro site to be configured for SSR or hybrid modes. My question is: why is this required? I was hoping to use keystatic as a GUI frontend to enable non technical people to work with an Astro SSG blog (probably hosted on GitHub pages or the like). Is this simply not possible? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Hey! It's because the API routes in the Keystatic Admin UI are doing some reads/writes on the file system (or GitHub repo), which need to happen on the server. The frontend itself can totally be all pre-rendered HTML. Perhaps you can deploy the Keystatic Admin UI somewhere else that supports Node.js, and deploy your Astro site on github pages? https://thinkmill.com.au is an example of an Astro site (running as pre-rendered HTML, SSG) deployed on Vercel, and only the admin UI routes are server-rendered. It's all deployed together to enable folks to update the site without accessing the codebase, and it works great 👍 |
Beta Was this translation helpful? Give feedback.
-
This could have been avoided if keystatic was provided as a separate process without needing to know about nextjs or astro and keystatic admin was entirely clientside. @curioustechizen you should probably look at using DecapCMS instead since it's admin interface is entirely client side where you can then:
I was doing something like this using nextjs and contentlayer (looks like they have a nextjs mdx renderer now) and i was able to publish completely static exports whilst using the decapcms interface.
|
Beta Was this translation helpful? Give feedback.
-
If you're only going to use Keystatic for local development, you can set the Astro configuration like this: const isDev = process.env.NODE_ENV === "development"
export default defineConfig({
integrations: [
/* ... other integrations like react and markdoc ... */
... isDev? [keystatic()] : [] // uses the integration conditionally
],
output: isDev? 'hybrid' : 'static' // only set hybrid rendering for dev mode
}) And set Keydocs to local mode. |
Beta Was this translation helpful? Give feedback.
Hey!
It's because the API routes in the Keystatic Admin UI are doing some reads/writes on the file system (or GitHub repo), which need to happen on the server.
The frontend itself can totally be all pre-rendered HTML. Perhaps you can deploy the Keystatic Admin UI somewhere else that supports Node.js, and deploy your Astro site on github pages?
https://thinkmill.com.au is an example of an Astro site (running as pre-rendered HTML, SSG) deployed on Vercel, and only the admin UI routes are server-rendered. It's all deployed together to enable folks to update the site without accessing the codebase, and it works great 👍