Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Go headless but don't lose your head
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Andy Adiwidjaja
September 24, 2020
Technology
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go headless but don't lose your head
Use NextJS+Headless Silverstripe CMS. Talk at Virtual StripeCon Europe 2020
Andy Adiwidjaja
September 24, 2020
More Decks by Andy Adiwidjaja
See All by Andy Adiwidjaja
Printing with Puphpeteer
adiwidjaja
0
510
Other Decks in Technology
See All in Technology
protovalidate-es を導入してみた
bengo4com
0
160
MIERUNE JCT 発表資料「宇宙から伊能忠敬ごっこ」
syuchimu
0
190
新規事業を牽引する技術選定 〜フルスタックTypeScript開発の実践事例〜
nullnull
3
370
会社紹介資料 / Sansan Company Profile
sansan33
PRO
18
420k
EventBridge Connection
_kensh
5
660
Rancherの紹介&Update情報(RancherJP Online Meetup #09)
yoshiyuki_kono
0
130
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
260
トークン数だけでは測れない — Claude Code 組織展開の効果検証から学んだこと
makikub
0
140
新アーキテクチャ「TiDB X」解説とDedicated比較 TiDB Cloud Premiumのゲーム運用活用を検証
staffrecruiter
0
120
社内 AI エージェント Synapse と セマンティックレイヤーの育て方
hiroakis
0
390
いまさら聞けない人のためのAIコーディング入門
devops_vtj
0
130
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
390
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
150
The Limits of Empathy - UXLibs8
cassininazir
1
350
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Transcript
Go headless, but don’t lose your head Andy Adiwidjaja Virtual
StripeCon Europe, 24.09.2020
Headless is here to stay and Silverstripe CMS is the
best open source solution
Overview Why SSR? Should I care? Why headless Silverstripe CMS?
How can I start?
Why SSR? Should I care? Is it worth it?
Me - had projects as a NextJS developer - was
forced to work with strange backends - would like to use Silverstripe CMS - launches own projects with NextJS+SilverstripeCMS
Going SSR Disadvantages of Single Page Apps: - SEO -
Browser history - Time to first render Solutions: - Server-side-rendering - Static generators (Graphic: microsoft.com)
Yeah, right Stacey Trooster StripeCon EU 2019
Headless CMS, React, SSR? 2001 2003 Plain PHP, Templating with
Smarty 2010 CMS, SASS, JQuery, Ajax 2015 CMS/Framework, SASS, React / Angular 2020 Plain HTML, Dreamweaver Templates
Demo https://kulturellebildung-sh.de/ Loads pages as XHR Loads HTML on Reload
Works without JavaScript!
NextJS getStaticProps getStaticPaths: - Fetch data at Build time New:
“static can also be dynamic” - getStaticProps can revalidate - getStaticPaths can have fallback getServerSideProps: - Fetch data on each request
NextJS SSR
NextJS dynamic pages Default NextJS logic: pages in /pages folder.
Former solution: Custom server.js rewriting to /pages/index.tsx Now: /pages/[[...page]].tsx
So, why Silverstripe CMS as headless CMS?
Headless CMS Criteria: Simple setup Mostly config Low maintenance Frontend-independent,
but: Pages Page elements Navigation Custom Data Hosted CMS (examples): Contentful Kentico GraphCMS Expensive, Limitations. Self-hosted CMS: Strange new players, all old players with APIs
Silverstripe CMS - dev/build - Pages with Elemental - ModelAdmin
- Backend functionality - Backend integration! Basic admin interfaces are a matter of configuration, but configuration in code! Strength of Silverstripe: Create solutions! class Actor extends DataObject { private static $db = [ “Name” => “Varchar(255) ]; } class ActorAdmin extends ModelAdmin { private static $managed_models = [ Actor::class, ]; private static $url_segment=”actor”; private static $menu_title=”Actors”; }
Example: DBRD React Frontend Headless Silverstripe CMS Sync with MS
Dynamics 365 (SOAP) ModelAdmin for Control No pages, assets etc. Easy to map models in and out
How? https://github.com/adiwidjaja/silverstripe-nextjs-starter Demo - Elements - Preview - RedirectorPage
File structure .storybook Storybook config backend Silverstripe CMS pages NextJS
pages public NextJS static files src JavaScript code No templates!
Setup > git clone
[email protected]
:adiwidjaja/ silverstripe-nextjs-starter.git demo > cd demo
> vi .env # Configuration > cd backend && composer install # PHP dependencies > cd .. > yarn # JS dependencies > yarn dev # Dev server
JavaScript Stack - NextJS - React - Typescript - Styled-components
- Storybook const FaqElementStyled = styled.div``; const TextContent = styled.div` display: ${props => (props.visible ? 'block' : 'none')}; `; const FaqElement = ({ title, text, }) => { const [open, setOpen] = useState(false); return ( <FaqElementStyled> <h1 onClick={() => setOpen(!open)}>{title}</h1> <TextContent visible={open}>{text}</TextContent> </FaqElementStyled> ); };
Config .env
Backend: Models Page TextElement FAQElement - Title - Description -
Image - Text
GraphQL - Route - Page - Fields - readOne op
with Resolver - nestedQueries - Elements - Menu - Children
Backend: Resolver
GraphiQL Your single most important tool Working with GraphQL. composer
require --dev silverstripe/ Graphql-devtools Demo
Client: GraphQL /src/utils/api.ts Called by getServerSideProps
Tricks BaseElementalExtension: - getContentFields: Waiting for GraphQL 4 Page: -
FrontendLink - Menu - PreviewLink Cannot use LinkOrSection, as Director::get_curr_page() uses Controller::curr(), which is not available.
Hosting - Silverstripe CMS: Standard - Javascript: Start with pm2
- NGinx: - /api: Rewrite to Silverstripe public folder - /: Proxy to Javascript-Server location ^~ /api { alias [...]/demo/backend/public; try_files $uri $uri/ @silverstripe; [...] } location @silverstripe { rewrite /api/(.*)$ /api/index.php?$1 last; } location ~ ^/ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:3000; } > yarn && yarn build > pm2 start yarn --interpreter bash --name app -- start > pm2 restart app
Conclusion SSR is no silver bullet Headless is here to
stay SSR+Headless Silverstripe CMS is easy to setup I would like to see a positioning for Silverstripe CMS as a headless CMS.
Thank you! I’m happy to speak with you about Headless+SSR.
Or anything else. Andy Adiwidjaja EMail:
[email protected]
Illustrations: Maria Müller-Leinweber https://www.mamuelei.de